Sometimes you want to know how many GPOs you have in a domain. Powershell provides a way to do this quickly and easily. Earlier today I tweeted about the way to do this in Windows 7 or Server 2008-R2, using the Microsoft-provided “GroupPolicy” PowerShell Module. Its as simple as:
(Get-GPO -All).Count
However, if you are not yet on these newer OS versions, you can still get this information from PowerShell. Specifically, my free PowerShell GPMC cmdlets provide nearly identical syntax to the MS ones, but on earlier versions of the OS (i.e. 2008, XP and 2003). The syntax is:
(get-sdmGPO *).Count
Quick, and easy!
Darren
I ran the command on Windows 2008 R2 with Administrative privileges, and I get error message stating The term Get-GPO is not recognized as the name of cmdlet. Any suggestions?
-Kash
This is the exact error:
PS C:\Personal> (get-sdmGPO *).Count
The term ‘get-sdmGPO’ is not recognized as the name of a cmdlet, function, scri
pt file, or operable program. Check the spelling of the name, or if a path was
included, verify that the path is correct and try again.
At line:1 char:12
+ (get-sdmGPO <<<< *).Count
+ CategoryInfo : ObjectNotFound: (get-sdmGPO:String) [], CommandN
otFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
make sure the SDM-GPMC module is loaded. That error indicates that the SDM Software GPMC module is not loaded. Use import-module sdm-gpmc prior to issuing that command.
Darren
i installed freware sdm cmdlets and get this error
get-sdmGPO : Unable to cast COM object of type ‘System.__ComObject’ to interface type ‘GPMGMTLib.GPMDomain’. This operation failed because the QueryInterface call on the
COM component for the interface with IID ‘{0077FDFE-88C7-4ACF-A11D-D10A7C310A03}’ failed due to the following error: No such interface supported (Exception from HRESULT:
0x80004002 (E_NOINTERFACE)).
At line:1 char:2
+ (get-sdmGPO *).Count
+ ~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-SDMgpo], InvalidCastException
+ FullyQualifiedErrorId : System.InvalidCastException,Sdmsoftware.PS.Commands.getSDMgpoCommand
Dmitry-
Is GPMC installed on this system? That’s a pre-requisite for this to work.
Thank you this saved me a ton of time. Worked perfect.