I have a custom psobject that a wish to export as un xml file
$array = @() Get-ADGroup -Filter * -SearchBase "$OU,$domain" | select-object "distinguishedName","GroupScope","name" | % { $array += New-object PSObject -Property([ordered]@{"Name"="$($_.Name)"; "GroupScope" = "$($_.GroupScope)"; "DistinguishedName" = "$($_.distinguishedName)"; "Members"="$((Get-ADGroupMember $_.Name | Select-Object Name).Name)"}) }#end foreach $date = get-date -Format yyyyMMdd Switch ($ExportType) { HTML { $array | ConvertTo-Html -as List | Out-File "$Outfolder\ADGroups-html-$date.html" } XML { $array | ConvertTo-Xml | Out-File "$Outfolder\ADGroups-xml-$date.xml" } CSV { $array | ConvertTo-Csv| Out-File "$Outfolder\ADGroups-csv-$date.csv" } }#end switch
The export works fine with csv and HTML but i can’t figure out why its failling with the XML