One of the most often asked for things in an IT department is a current list of servers. Key word here, CURRENT. Keeping an accurate inventory of the servers on your network can be a daunting task. And the larger your network, the more daunting the task can become.
Thankfully, PowerShell gives you a way to collect this information from Active Directory.
To run the scripts presented in this article, you will need to be running one of the following:
- Windows 7 (or newer) with the Remote Server Administration Tools (RSAT) installed.
- Windows Server 2008 R2 with RSAT installed.
Assuming you are logged on to your computer with a domain account, you can run the following PowerShell command to retrieve a list of servers in your domain:
Get-ADComputer -Filter {OperatingSystem -like "*windows*server*"}
This command produces the following output on my test network:
Get-ADComputer -Filter {OperatingSystem -like "*windows*server*"} -Properties OperatingSystem |
Select-Object -Properties SamAccountName,OperatingSystem
This command truncates the output as follows:
Get-ADComputer -Filter {OperatingSystem -like "*windows*server*"} -Properties OperatingSystem |
Select-Object -Properties SamAccountName,OperatingSystem |
Export-Csv -Path C:\Temp\Test.csv -NoTypeInformation
If you found this blog helpful or have a question, please leave a comment.
Thanks for reading.
No comments:
Post a Comment