First we have to get a list of the computers. I used the get-adcomputer cmdlet for this task.
Get-ADComputer -Filter {operatingsystem -like "*professional*"} | select -Expand Name > c:\lists\computers.txt
This command will list all computers with Professional in the name.
Then using WMI I use the list i created above to output a list of all the computers and the logged in user if there is one.
Get-WmiObject -Class Win32_Computersystem -Computer (Get-Content "c:\lists\computers.txt") | Select Name, UserName | out-gridview
I use these commands for my servers with just a quick edit to the filter in the first command. This helps me after a patch cycle to make sure there are no users logged into any of the servers.
Thats it for now.
Rich
No comments:
Post a Comment