Hello, I am attempting to pull a list of computers from AD, store them in a variable and run a script that will determine the UAC status of those computers.
Here is what I have so far:
$time = (Get-Date).Adddays(-90)
$vm = (Get-ADComputer -Filter { OperatingSystem -Like ‘Windows Server’-and LastLogonTimeStamp -gt $time } | Where-Object {$_.distinguishedname -notmatch “OU=Domain Controllers”} | Select-Object -ExpandProperty Name)
$cred = get-credential
Invoke-Command -VMName $vm -ScriptBlock {REG QUERY HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\ /v EnableLUA} -Credential $cred
It looks like the query works just fine. I get a list of servers that are not domain controllers and omit inactive servers. The issue is when I run the last line an error returns: “The input VMName xxxxxx does not resolve to a single virtual machine.”
Any help is greatly appreciated!