Hello
I am trying to find a way to get the windows releaseid from a remote computer, but am having a hard time finding a way to do it.
I'm trying to use:
(Get-ItemProperty -Path ‘HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion’).ReleaseId
But have not found a way to tell it to look on a remote system. I have also tried using the invoke-command and using the -computername, but again, it fails.
$hostname ="City-Spare71" $OScompID = Get-ADComputer -Filter {Name -eq $Hostname} | Select Name Invoke-Command -Computername $OSCompID {(Get-ItemProperty -Path ‘HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion’).ReleaseId}
Here's the error:
Invoke-Command : One or more computer names are not valid. If you are trying to pass a URI, use the -ConnectionUri parameter, or pass URI objects instead of strings. At line:1 char:1+ Invoke-Command -Computername $OSCompID {(Get-ItemProperty -Path ‘HKLM ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo : InvalidArgument: (System.String[]:String[]) [Invoke-Command], ArgumentException+ FullyQualifiedErrorId : PSSessionInvalidComputerName,Microsoft.PowerShell.Commands.InvokeCommandCommand
$OSCompID does return the right value.
Any suggestions? I'm looking for a 1 liner
Thank You
Terry