Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Script to find some Attributes from Servers

$
0
0

Hello,

I am trying to find Description, OS, and DNSHOstname from some servers in my list.

I know that some servers are not longer valid, so I am trying to build a script (below) that provides me that information and maybe saying something like FOUND no FOUND...

Could someone help me seeing my error?

I get an error message when the script does not find the script

Thanks

$Servers = Get-Content 'C:\Jim Reports\ServerOwner.txt'
foreach ($Server in $Servers) {


    if ($test = Get-ADComputer -Identity $server -ErrorAction Stop) {

        Get-ADComputer "$server" -Properties description , operatingsystem, dnshostname |
        Select Name, description, operatingsystem, dnshostname |
        Export-CSV "C:\Jim Reports\ServerInfo.csv" -NoTypeInformation -Encoding UTF8
}}



Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>