I have a Powershell-Script for Windows Server Update Service to automatically approve Updates.
Approved Updates get listed in an XML-File. To achieve that I export the selected data (Title, Arrivaldate and Update-ID) with Export-CliXml
into a File:
That worked for quite some time now.
Since a few days, when a new list has to be established, the exported results have no nodes, no structure, no elements ..
What am I doing wrong?
I need these Nodes in a further process. When I import the xml file with import-CliXml
, I can't properly iterate through the values like
$List[x][x]
I know the problem: the xml file is not structured. But I am not able to solve it. Can someone help me?
Here is sample code which is similar to mine (which will obviously only work on a Windows Server with WSUS installed):
$List = @()
$Updates_Pretest = $WSUS.GetUpdates() | select -First 10
if ($Updates_Pretest.count -gt 0)
{
foreach ($Update in $Updates_Pretest)
{
$List += @($Update.Id.UpdateId.Guid;(Get-Date -Format "MM.dd.yyyy");$Update.title)
}
}
$List | Export-Clixml -Path ("c:\" + "Test.xml")