Add 'usercount.ps'
This commit is contained in:
parent
675c20c96a
commit
081dff7250
26
usercount.ps
Normal file
26
usercount.ps
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
$mailto=
|
||||||
|
$mailfrom=
|
||||||
|
$mailserv=
|
||||||
|
|
||||||
|
Function ADCOUNT
|
||||||
|
{
|
||||||
|
Get-ADOrganizationalUnit -filter * -property Description |
|
||||||
|
foreach {
|
||||||
|
$u=Get-ADUser -filter * -searchbase $_.distinguishedname -ResultPageSize 2000 -resultSetSize 500 -searchscope Onelevel
|
||||||
|
$total=($u | measure-object).count
|
||||||
|
$Enabled=($u | where {$_.Enabled} | Measure-Object).count
|
||||||
|
$Disabled=$total-$Enabled
|
||||||
|
New-Object psobject -Property @{
|
||||||
|
Name=$_.Name;
|
||||||
|
OU=$_.Distinguishedname;
|
||||||
|
Description=$_.Description;
|
||||||
|
TotalUsers=$Total;
|
||||||
|
Enabled=$Enabled;
|
||||||
|
Disabled=$Disabled
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ADCOUNT | out-file c:\Windows\Temp\adcount.txt
|
||||||
|
$datum = (get-date -uformat "%B %Y")
|
||||||
|
send-MailMessage -To $mailto -Subject "AD Count output" -Body "Rapport created on $datum" -SmtpServer $mailserv -From $mailfrom -Attachment "c:\windows\temp\adcount.txt"
|
||||||
|
remove-item c:\windows\temp\adcount.txt
|
Loading…
x
Reference in New Issue
Block a user