Skip to content

Instantly share code, notes, and snippets.

@PrateekKumarSingh
Created October 4, 2019 13:07
Show Gist options
  • Save PrateekKumarSingh/2523a6424946cc01e9b78d998a9e67c9 to your computer and use it in GitHub Desktop.
Save PrateekKumarSingh/2523a6424946cc01e9b78d998a9e67c9 to your computer and use it in GitHub Desktop.
# Method 9 - From String using `-Match` operator
$Hashtable = @{}
@"
name=prateek
age=29
skills=powershell
"@ -split [System.Environment]::NewLine | ForEach-Object {
if ($_ -match '^(.*)=(.*)'){
$Hashtable[$matches[1]] = $matches[2]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment