Skip to content

Instantly share code, notes, and snippets.

@B-Art
B-Art / StringExtension.ps1
Last active July 23, 2024 19:43
#Powershell #Pwsh #Core `Chop String into choosen lengths Positive from Begin to End, Negative from End to Begin.`
using namespace System.Runtime.CompilerServices
# Define the type extension for the System.String class
class StringExtensions {
[Extension()]
static [String[]] Chop([String]$Value) {
return [StringExtensions]::Chop($Value, 2)
}
static [String[]] Chop([String]$Value, [int]$Length) {
@B-Art
B-Art / SpltANDConcer.ps1
Last active July 23, 2024 19:15
#Powershell #Pwsh #Core SplitANDconcer `Transform a list of Named Values into an object`
(@"
naam: ZBVAHAP001
SN: CNGHJSS8S2
Mac: B0B367C976F0
Naam: ZBVAHAP010
SN: CNG7JSSJ2G
Mac: 904C81C8AC22
Naam: ZBVAHAP009
SN: CNGHJSS8RM
MAC: B0B867C97A4E