Taking on PowerShell one cmdlet at a time

Share this post:This blog post is part of an ongoing series by Adam Gordon. Adam will walk through each PowerShell command every week, explaining when and how to use them. Adam will be covering Get-GPO this week.

When should you use Get-GPO
The Get-GPO cmdlet will give you one Group Policy Object (GPO), or all GPOs in a given domain. To get one GPO, you can either specify it by its display name (or by its globally unique ID (GUID), or all GPOs in the domain using the All parameter.
This cmdlet returns one to several objects that correspond to the requested GPOs. The default behavior of the requested GPOs is to print their properties to the display. However, you can pipe the output from the Get-GPO cmdlet into other Group Policy cmdlets.
What version of PowerShell should I use for this blog?
Get the PowerShell Version for your machine
This command displays the PowerShell version information for your machine.

How to use Get–GPO
One GPO per domain
Get-GPO -Name “PowerShell Policy”
This command will give you the GPO called Group Policy Test. The GPO must be in the domain of user running the session (or for startup and shut down scripts, the computer). The primary domain controller (PDC) can be contacted to obtain the GPO information.

You can get a single GPO using your 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 running the session (or the computer that is being used for startup and shut down scripts) is not ITP.LOCAL, trust must exist between these domains. The command retrieves the GPO information from the PDC (in ITP.LOCAL).

All GPOs available for a domain
Get-GPO -ALL -Domain “ITP.LOCAL”
This command will get all GPOs from the ITP.LOCAL domain.

Learn last week’s command: Clear-DnsServerStatistics.
Do you need PowerShell training? ITProTV offers PowerShell online IT training courses.