Get-GPO | Taking on PowerShell one cmdlet at a time | Weekly Blog

Share this post:

This is a part of an on-going blog series written by Adam Gordon. Each week, Adam will walk you through a PowerShell command, showing you when and how to use each one. This week, Adam covers Get-GPO.

When to use Get-GPO?

The Get-GPO cmdlet gets one Group Policy Object (GPO) or all the GPOs in a domain. You can specify a GPO by its display name or by its globally unique identifier (GUID) to get a single GPO, or you can get all the GPOs in the domain through the All parameter.

This cmdlet returns one or more objects that represent the requested GPOs. By default, properties of the requested GPOs are printed to the display; however, you can also pipe the output of the Get-GPO cmdlet to other Group Policy cmdlets.

What version of PowerShell am I using for this blog?

Get the PowerShell Version from your machine:

$PSVersionTable

This command shows you the PowerShell version information on your machine.

How to use Get-GPO?

Get a single GPO from a domain:

Get-GPO -Name “PowerShell Policy”

This command gets the GPO named Group Policy Test. The GPO must exist in the domain of the user that is running the session (or, for startup and shutdown scripts, the computer). The command gets the GPO information by contacting the primary domain controller (PDC).

Get a single GPO by GUID: 

Get-GPO -Guid 1de91c57-172d-4271-99bb-e76b60a0caf1 -Domain “ITP.LOCAL”

This command gets the GPO that has the ID (GUID) 1de91c57-172d-4271-99bb-e76b60a0caf1 in the ITP.LOCAL domain. If the domain of the user that is running the session (or, for startup and shutdown scripts, the computer) is different than ITP.LOCAL, a trust must exist between the two domains. The command retrieves the GPO information by contacting the PDC (in the ITP.LOCAL domain).

Get all GPOs from a domain: 

Get-GPO -ALL -Domain “ITP.LOCAL”

This command gets all the GPOs in the ITP.LOCAL domain.

Learn last week’s command: Clear-DnsServerStatistics.

Need PowerShell training? Check out ITProTV’s PowerShell online IT training courses.