I\'m currently trying to write a powershell function which works with the output of the Lync powershell cmdlet \"Export-CsConfiguration -AsBytes\". When using implicit Power
Answering my own question here, in case it proves useful to others: (N.B. Requires .NET 4.5)
It looks like using System.IO.Compression.ZipArchive in combination with System.IO.Memorystream is the way forward. I've got this now:
Function Load-CsConfig{
[System.Reflection.Assembly]::LoadWithPartialName('System.IO.Compression') | Out-Null
$ZipBytes = Export-CsConfiguration -AsBytes
$ZipStream = New-Object System.IO.Memorystream
$ZipStream.Write($ZipBytes,0,$ZipBytes.Length)
$ZipArchive = New-Object System.IO.Compression.ZipArchive($ZipStream)
$ZipEntry = $ZipArchive.GetEntry('DocItemSet.xml')
$EntryReader = New-Object System.IO.StreamReader($ZipEntry.Open())
$DocItemSet = $EntryReader.ReadToEnd()
return $DocItemSet
}
Which does exactly what I need.
Thanks all :)