Hello
I have created a script and I wondered if anyone could suggest any improvements (not hard i'm sure).
Basically, all my AD accouts have either the type of accounts they are (System, Departmental etc...) or the users job title in the Title field. My script goes through AD and basicaly counts up how many there are of each account and then displays this to the screen.
The problem I am finding is that this takes up a massive amount of memory and my pc is not usable whilst PowerShell runs the script.
Any suggestion on how to improve this woud be most welcomed.
# Script to check for various types of accounts
$Departmental = get-qaduser -title Departmental -sizelimit 0
$Training = Get-QADUser -title Training -sizelimit 0
$System = Get-QADUser -title System -sizelimit 0
$Service = Get-QADUser -title Service -sizelimit 0
$Users = Get-QADUser -sizelimit 0 | where { $_.title -ne "Training" -AND "Departmental" -And "Service"}
$Total = Get-QADUser -Sizelimit 0
write-host "There are a total of" $Total.count "Accounts"
write-host "There are a total of" $Users.count "User Accounts"
write-host "There are a total of" $System.count "System Accounts"
write-host "There are a total of" $Departmental.count "Departmental Accounts"
write-host "There are a total of" $Service.count "Service Accounts"
write-host "There are a total of" $Training.count "Training Accounts"
Thanks
Lee