Wednesday 22 April 2020

Check OS Information List of Computers


$dcs = Get-Content C:\temp\server.txt

foreach ($dc in $dcs){

    If ((Get-ADComputer -Filter 'Name -like $dc') -ne $null)
    {
    Get-ADComputer -Identity $dc -Properties * | Select-Object name,OperatingSystem | Export-Csv C:\temp\3.csv -Append -NoTypeInformation

    }

    else {
    "$DC" |Select-Object @{name="Name";e={$Dc}},OperatingSystem | Export-Csv C:\temp\3.csv -Append -NoTypeInformation
    }
    } 

No comments:

Post a Comment