i just need to have an csv as output with the name of the servers in one column and the result in the second column. I cannot use the export-csv cmdlet because im using a old version of PS. Thank you very much for your help!
$servers= Get-Content -path .\Server_List.txt
Function get-UserAccountControl ($server)
{
[string]$RegPath = "Software\Microsoft\Windows\CurrentVersion\Policies\System"
[string]$RegValue = "EnableLUA"
$OpenRegistry = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine,$server)
$subKey = $OpenRegistry.OpenSubKey($RegPath,$false)
$UAC = ($Subkey.GetValue($RegValue) -eq 1)
if ($uac -eq 1 )
{
return( " uac is enabled")
}
else
{
return (" uac is disabled")
}
}
foreach ($srv in $servers)
{
write-host "The server $srv"
$useraccount= get-UserAccountControl($srv)
write-output $useraccount
}