I've been using the very helpful PSRemoteRegistry module to gather information from multiple servers on my network. However, I've found that it throws an error when requesting Registry information if the server name includes a hyphen.
This code:
$Date = Get-RegValue -ComputerName $Computer.Name -Key "SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\Results\Install" -Value LastSuccessTime
works just fine if $Computer.Name contains something like "Server1" but it fails when it contains something like "SQL-Server". It appears that it is breaking the name into two parts.
The error is:
Exception calling "OpenRemoteBaseKey" with "2" argument(s): "The network path was not found.
"
At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSRemoteRegistry\Get-RegValue.ps1:261 char:5
+ ... $reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : IOException
Any help with a way around this problem would be really appreciated.