Here is the Error:
Get-WmiObject : Cannot validate argument on parameter ‘ComputerName’. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
At C:\Scripts\CheckWINrmService.ps1:9 char:106
One, never ever post real corporate data on a public forum. Only use fake name.
Pull this data a replace it with fake names. No one needs to know the real internal server / host names in your environment to help here.
Secondly, the post has you have it is not a CSV, since there are no commas, it is fixed length and the whole OS part is not really a needed thing.
Now a CSV can have any single char delimiter you want, so that space is fine, except for the OS name section, On using Import-Csv you should use the -Delimiter switch to specific that space as your delimiter.
You can do that here, but that OS section will get truncated, which is not really needed for what you are after. You only really need the short name. That first column.
Why are you not just using the Test-WsMan and Get-Service cmdlet for this test?
Description
The Test-WSMan cmdlet submits an identification request that determines whether the WinRM service is running on a local or remote computer. If the tested computer is running the service, the cmdlet displays the WS-Management identity schema, the protocol version, the product vendor, and the product version of the tested service.
# Get parameters, examples, full and Online help for a cmdlet or function
(Get-Command -Name Import-Csv).Parameters
Get-help -Name Import-Csv -Examples
Get-help -Name Import-Csv -Full
Get-help -Name Import-Csv -Online
Import-Csv -Path 'D:\Lists\Servers.csv' -Delimiter ' '
(Get-Command -Name Test-WSMan).Parameters
Get-help -Name Test-WSMan -Examples
Get-help -Name Test-WSMan -Full
Get-help -Name Test-WSMan -Online
Test-WSMan -ComputerName 'ServerName' -Verbose
Get-Help about_*
Get-Help about_Functions
# Find all cmdlets / functions with a target parameter
Get-Help * -Parameter Append
# All Help topics locations
explorer "$pshome\$($Host.CurrentCulture.Name)"
So, someting like…
($ServerList = Import-csv -Path D:\Temp\DevSvrs.csv -Delimiter ' ')
ServerName : CTDEV02
DNS : ctdev02.dev.contoso.com
Name : poweredOn
Powerstate : Microsoft
OperatingSystem : Windows
ServerName : tedev02
DNS : tedev02.dev.contoso.com
Name : poweredOn
Powerstate : Microsoft
OperatingSystem : Windows
ServerName : CatDev02
DNS : catdev02.dev.contoso.com
Name : poweredOn
Powerstate : Microsoft
OperatingSystem : Windows
ServerName : BDEV02
DNS : bdev02.dev.contoso.com
Name : poweredOn
Powerstate : Microsoft
OperatingSystem : Windows
ServerName : web01
DNS : WEB01.dev.contoso.com
Name : poweredOn
Powerstate : Microsoft
OperatingSystem : Windows
$ServerList | %{
If(Test-WSMan -ComputerName $_.ServerName -Verbose)
{
Get-Service -ComputerName $_ |
Select Name, DisplayName, Status, StartMode, StartType | Where-Object Name -eq 'WinRM'}
}
Else
{Write-Warning -Message "WinRM test failed for $($_.ServerName)"}
No worries.
It happens ever so often, and I ping folks back as soon I see it.
As you can see in my response, I sanitized that before posting.
Yet, who knows who also it before I hit you back.
So, it may turn out to be nothing for you and you org, but I’d keep an eye for any odd search’s / requests to those FQDN’s.