Few of the articles are posted as Images, Please use Laptop / Computers to go through the articles for best experience. For phone users, switch to Web Version

Please Share with your colleagues if you found these blogs informative. Happy Learning :-)

Powershell Script - Listing Empty GPOs

  #Created By - Abhishek Bansal

<#Read Me !! 

1. Script Usage - Finding Empty GPOs in the domain environment.

Script Logic -  Logic revolves around GPO Template & GPO Container user & computer version. So if  a policy is created but it's not configured with any setting or it's never been edited, then the Sysvol & AD Version for both the container & template are 0.

Below Snap for reference -

2. Refer EmptyGPos.csv for the output & below is the code. #>






import-module grouppolicy

$gpos = Get-GPO -All

foreach ($gpo in $gpos)

{

    if (($gpo.Computer.DSVersion -eq 0 -and $gpo.User.DSVersion -eq 0) -and ($gpo.Computer.SysvolVersion -eq 0 -and $gpo.User.SysvolVersion -eq 0))

    {

         $gpo | Select @{n="GPO Name";e={$_.Displayname}},DomainName,Owner,@{n="GUID";e={$_.ID}},GPoStatus,CreationTime,ModificationTime | Export-Csv ./EmptyGPO.csv -NoTypeInformation -Append

    }

}

No comments:

Post a Comment