In the previous example we showed the code required to read registry values remotely from another machine using the old-fashioned DCOM protocol.
If you can use PowerShell remoting, things become much easier. You now can simply take code that would run locally on your machine, and “beam” it over to the target machine(s):
# adjust this to a remote computer of your choice # (or multiple computers, comma-separated) # PowerShell remoting needs to be enabled on that computer # and you need to have local Admin privileges on that computer $ComputerName = 'pc01' # execute this code remotely on the machine(s) $code = { # read the given registry value... Get-ItemProperty -Path hklm:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\* | # and show the reg values with the names below Select-Object DisplayName, DisplayVersion, UninstallString } # "beam" the code over to the target computer(s), and retrieve # the result, then show it in a grid view window Invoke-Command -ScriptBlock $code -ComputerName $ComputerName | Out-GridView
By using PowerShell remoting, you just need to make sure that the prerequisites for PowerShell remoting are met. You can enable PowerShell remoting on a computer using this command (requires local Admin privileges):
PS C:\> Enable-PSRemoting -SkipNetworkProfileCheck -Force