Skip to content

Instantly share code, notes, and snippets.

@cernoel
Last active June 22, 2017 06:01
Show Gist options
  • Save cernoel/0b14267cbe32bc05927beb9f68502bcf to your computer and use it in GitHub Desktop.
Save cernoel/0b14267cbe32bc05927beb9f68502bcf to your computer and use it in GitHub Desktop.
Store and Load a KeyValue-Object to File - EasyMode
#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