Skip to content

What is the PowerShell equivalent of the GPResult cmd?

Brock Bingham candid headshot
Brock Bingham|February 11, 2021
What’s The GPResult CMD Equivalent In PowerShell
What’s The GPResult CMD Equivalent In PowerShell

If you’re anything like me, you’ve been reluctant to stop using CMD and start using PowerShell. I’m envious of those sysadmins who realized PowerShell’s worth, immediately adopted it, and started learning how to utilize its capabilities. Kind of like how I’m jealous of those who bought into Bitcoin when it was super cheap. Well, I’m here to tell you that you’re not too late to jump on the PowerShell bandwagon. PowerShell is only going to become more prevalent, and if you look at the job market, it’s already a highly requested skillset, if not mandatory in a lot of cases.

Now that I’ve hopefully got you motivated to start venturing into the world of PowerShell, let’s focus on taking the common CMD commands we know and love and learn how to apply them in PowerShell. If the title wasn’t enough of a giveaway, we’re going to take a look at the command GPResult and learn what the equivalent cmdlet is in PowerShell. Before we dive into PowerShell, let’s go over what GPResult does.

GPResult is a command-line utility used to display the applied group policy of a user and computer. This command can be run locally or against a remote host. The Resultant Set of Policy (RSoP) information can be saved as an Html or an Xml file. The data can be useful for troubleshooting user and computer group policy assignments. Now that we know what GPResult does let’s dive into the PowerShell equivalent.

The PowerShell Equivalent of GPResult is Get-GPResultantSetOfPolicy

NAME     Get-GPResultantSetOfPolicy SYNOPSIS     Gets and writes the RSoP information for a user, a computer, or both to a file. SYNTAX     Get-GPResultantSetOfPolicy [-Computer <String>] [-User <String>] -Path <String> -ReportType {Xml | Html} [<CommonParameters>] DESCRIPTION     The Get-GPResultantSetofPolicy cmdlet gets and writes the Resultant Set of Policy (RSoP) information for a user, a computer, or both to a file.

NOTE

If you get an error when you try to run Get-GPResultantSetOfPolicy, make sure you are running PowerShell as an administrator. Most commands in PowerShell require administrative privileges to run. Also, RSAT: Group Policy Management Tools will need to be installed If you are running these commands from a Windows 10 computer.

Examples of Get-GPResultantSetOfPolicy

Now that we know the proper PowerShell command for GPResult, let’s look at a few examples of how to use it. If you’re new to PowerShell, let me give you a quick tip that will save you some time and a headache or two. There is a feature called tab completion in PowerShell that will finish inputting your command if you hit the Tab key on your keyboard after typing in the first few letters. Since Get-GPResultantSetOfPolicy is a considerably longer command than GPResult, do yourself a favor and use the tab completion feature in PowerShell by typing in Get-GPRes and hitting the Tab key on your keyboard to auto-complete the command. If you type in fewer characters and tab completion doesn’t give you the correct command, just keep hitting Tab, and PowerShell will cycle through all of the possible command options based on what you’ve entered so far.

Get-GPResultantSetOfPolicy Example 1:

Get-GPRsultantSetOfPolicy -ReportType Html -Path “c:\report.html”
gp5 (1)Get-GPResultantSetOfPolicy Example

This cmdlet is comparable to the typical ‘gpresult /h “c:\report.html”’ command. It will gather information on the applied group policies for the local user and local computer and save the RSoP data to an Html file.


Get-GPResultantSetOfPolicy Example 2:

Get-GPResultantSetOfPolicy -User "user" -Computer "computer" -ReportType Html -Path "c:\remotereport.html"
Get-GPResultantSetOfPolicy Example

This example is similar to the first example, except it targets a specific user on a remote computer. You can verify the user and computer in the generated report.

verify the user and computer in the generated report

Get-GPResultantSetOfPolicy Example 3:

$list = "computer1", "computer2" Foreach ($Machine in $list){ Get-GPResultantSetOfPolicy -Computer $Machine -ReportType Xml -Path “c:\Group_Policy_Reports\$($Machine)_$(get-date -f MM-dd-yyyy).Xml” }
Get-GPResultantSetOfPolicy Example

In this example, we are using a Foreach loop to run the Get-GPResultantSetOfPolicy command against multiple computers. The $list variable contains the computer names we want to run the command against. $Machine is a placeholder variable that will represent the current item from the list. $Machine will take a value from the $list variable and hold onto it while running through the loop. Once the loop has finished, $Machine will be assigned the next value from the $list variable. The line “c:\Group_Policy_Reports\$($Machine)_$(get-date -f MM-dd-yyyy).Xml” instructs PowerShell to save the file using the computer name followed by the date in a folder called “Group_Policy_Reports.” The resulting files should look like this.

using a Foreach loop to run the Get-GPResultantSetOfPolicy

Wrapping Up

If you haven’t started learning PowerShell yet, now’s the time. These examples don’t even scratch the surface of what’s possible. With PowerShell, you can automate many of the mundane administrative tasks you spend way too much time manually performing. When I compare PowerShell to CMD, I can’t help but think of the song “Anything You Can Do (I Can Do Better).”

Are you interested in taking your PowerShell game to the next level? Subscribe to the PDQ Blog. With many useful PowerShell guides already available, we will continue to provide a constant stream of new PowerShell content to help you get caught up to that overachieving coworker who’s been reading PowerShell books since 2006.

If YouTube tutorials are more your thing, check out our PowerShell playlist. Sit back and relax as Jordan’s smooth baritone vocals guide you through increasingly complex PowerShell lessons. With help from PDQ.com, you’ll be a PowerShell pro in no time!

Brock Bingham candid headshot
Brock Bingham

Born in the '80s and raised by his NES, Brock quickly fell in love with everything tech. With over 15 years of IT experience, Brock now enjoys the life of luxury as a renowned tech blogger and receiver of many Dundie Awards. In his free time, Brock enjoys adventuring with his wife, kids, and dogs, while dreaming of retirement.

Related articles