Last active
June 22, 2017 06:01
-
-
Save cernoel/0b14267cbe32bc05927beb9f68502bcf to your computer and use it in GitHub Desktop.
Store and Load a KeyValue-Object to File - EasyMode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Save File | |
################## | |
$MyDict = @{} | |
$MyDict.Add($SomeKey1, $SomeValue1) | |
$MyDict.Add("KEY2", "Value2") | |
$MyDict.Add("KEY3", "Value3") | |
try { | |
$MyDict | Export-Clixml $FilePathToDict | |
} | |
catch { | |
Write-Warning("Error Writing Dictionary: " + $FilePathToDict); | |
} | |
$MyDict.Clear() | |
#Read File | |
################ | |
$MyDict = Import-Clixml $FilePathToDict | |
$Value = [string]$MyDict["KEY2"] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment