PowerShell command to extract Group policy result for a list of Servers

By | April 7, 2016

If you are looking for a PowerShell command that can run against list of computers to obtain computer policy settings in your domain environment, you can use this to compare with working and not working servers to fix the issue and also used for GPO reporting

Also Read: Enable Powershell Remoting on Windows server 2008 R2 and 2012

Input file needs to be created (serverlist.txt) and c:\temp location and update the file with server list which will be used to extract the group policy output

Run below PowerShell command to export all Group Policies to Text File:

Need to import the PowerShell module before run the command then only the GroupPolicy related command will work

Import-Module GroupPolicy

Run the PowerShell script below:

$RemoteComputers = Get-Content -Path C:\temp\serverlist.txt

foreach ($computer in $RemoteComputers)
{
Get-GPResultantSetOfPolicy -Computer $computer -ReportType htm -Path C:\temp\rsop\$computer.htm
}

Out put file will be created for each servers in the input file with servername.htm on c:\temp\resop\, now you have GroupPolicy result for all the servers

Also Read: Interesting oneline script written using windows command  

Difference between windows server 2008 and 2012

 

Leave a Reply

Your email address will not be published. Required fields are marked *