Fortunately Powershell makes this laborious task fairly straight forward. Using just a few lines of code, I've loaded in the export file along with a file of users that should be removed; then filter through the user objects in the XML and write the results out to a new file.
$usernames = Get-Content excludedUsers.txt [xml]$xmlFile = Get-Content ".\users-export.xml" $xmlFile.Application.Users.User | where-object {$usernames -notcontains $_.username} | % {$_.ParentNode.RemoveChild($_)} $xmlFile.OuterXml | Out-File .\users-export-filtered.xml
No comments:
Post a Comment