I have this bit of script and I am trying to get the results output to a CSV.
$time = (Get-Date).Adddays(-5)
$vm = (Get-ADComputer -Filter { OperatingSystem -Like ‘Windows Server’-and LastLogonTimeStamp -gt $time } | Where-Object {$_.distinguishedname -notmatch “OU=Domain Controllers”} | Select-Object -ExpandProperty Name)
Invoke-Command -ComputerName $vm -ScriptBlock {
$reg = REG QUERY HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\ /v EnableLUA
$hostname = hostname
write-host $hostname $reg
}
Any ideas?