将组策略中的内容导出至CSV格式

#将组策略首选项中的"本地用户和组"下的所有条目导出
$xml = Get-GPOReport -ReportType Xml -Name "China Desktop Policy"
$report = New-Item -ItemType file -Path C:\Toolkits\GPOAdminRight.CSV -Force
Add-Content -Path $report -Value "Name,EmpNo,Computer,Description"
$e = ($xml.gpo.computer.ExtensionData | where name -EQ 'local users and groups').Extension.LocalUsersAndGroups
$e.Group | foreach {
    $_.name + "," + $_.properties.members.member.name + "," + $_.filters.filtercomputer.name + "," + $_.desc
} | Out-File -FilePath $report -Append -Encoding ascii

 

posted @ 2015-05-08 17:16  dongdonggeorge  阅读(484)  评论(0编辑  收藏  举报