You're correct that the gpresult command primarily shows Group Policy results, which can include domain policies if the computer is part of a domain. To specifically view local policies on a remote PC (not just the domain policies), you can use a different approach.
Viewing Local Group Policies Remotely
To view local group policies on a remote computer, you can use the Get-GPResultantSetOfPolicy cmdlet for a more comprehensive view, or directly access the local policy settings with secedit.
However, using gpresult directly won’t give you local policies; here’s a step-by-step guide to retrieve them using secedit.
Method: Check Local Policies with secedit
Here's how to use Invoke-Command to run secedit on the remote computer:
-
Open PowerShell as Administrator.
-
Execute the following command:
Invoke-Command -ComputerName <RemotePCName> -ScriptBlock {
secedit /export /areas SECURITYPOLICY /log C:\security_policy.txt
Get-Content C:\security_policy.txt
}
Replace <RemotePCName> with the name or IP address of the target remote computer.
Explanation of Commands
secedit /export /areas SECURITYPOLICY /log C:\security_policy.txt: This command exports the local security policies to a file on the remote computer.
Get-Content C:\security_policy.txt: This retrieves the contents of the generated log file and displays it.
Example Command
If the remote computer is called RemotePC, the command would look like:
Invoke-Command -ComputerName "RemotePC" -ScriptBlock {
secedit /export /areas SECURITYPOLICY /log C:\security_policy.txt
Get-Content C:\security_policy.txt
}
Important Notes
-
Permissions: Ensure that you have administrative access on the remote machine where you are running the command.
-
PowerShell Remoting: PowerShell Remoting must be enabled on the remote computer (Enable-PSRemoting).
-
Temporary File: The security_policy.txt file will be created on the remote machine's C:\ drive. If your remote machine has restrictions on writing to the C: drive or different file system permissions, you might want to specify a different path.
-
Cleanup (Optional): If you wish, you can add an additional command to remove the temporary log file after reading it:
Invoke-Command -ComputerName <RemotePCName> -ScriptBlock {
secedit /export /areas SECURITYPOLICY /log C:\security_policy.txt
Get-Content C:\security_policy.txt
Remove-Item C:\security_policy.txt
}
This approach provides a practical way to check local security policies on remote machines without being influenced by domain settings.