by taheito at 2012-11-19 02:00:29
We have a parent OU called Schools that contains OU for each School, and each School OU contains a security group called â€SchoolName Teachers" that contains every School teachers when running the script to get each groups Total members and -NotLoggedOnFor X days it gives me the total number for all teachers and total -NotLoggedOnFor for all teachers not for each school separately .by kittH at 2012-11-19 06:29:30
this is the used script
( Get-QADGroup -Name "* Teachers" -SearchRoot "OU=Schools,DC=secedu,DC=qa" -SizeLimit 0 | Foreach{
$u=Get-QADGroup -Name "* Teachers" -SearchRoot "OU=Schools,DC=secedu,DC=qa" -SizeLimit 0 | Get-QADGroupMember
$f=Get-QADGroup -Name "* Teachers" -SearchRoot "OU=Schools,DC=secedu,DC=qa" -SizeLimit 0 | Get-QADGroupMember |get-qaduser -NotLoggedOnFor 47 -SizeLimit 0 -PageSize 2000
$FilePath = $FilePath = "c:\1\Teachers200.csv"
$total=($u | measure-object).count
$disabled=($u | where {$.AccountIsDisabled} | Measure-Object).count
$NotLoggedOnFor=($f | measure-object).count
$Enabled=$total-$disabled
$ActiveUsers=$Enabled-$NotLoggedOnFor
New-Object psobject -Property @{
Name=$.Name;
Group=$.DN;
Description=$.Description;
TotalUsers=$Total;
Enabled=$Enabled;
Disabled=$Disabled
ActiveUsers=$ActiveUsers}
})
Your initial query gets all of the groups named "* Teachers" in the Schools OU. You then run a foreach loop for each of those groups.by ArtB0514 at 2012-11-19 08:49:07
The first two items in the loop run the same query that generated the group list. Inside each loop you’re getting all of the users in all of the groups.
Try changing the lines to:
$u = $_ | Get-QADGroupMember
$f = $_ | Get-QADGroupMember | get-qaduser -NotLoggedOnFor 47 -SizeLimit 0 -PageSize 2000
There’s no need to use -SizeLimit or -PageSize on this Get-QADuser unless there are more than 1,000 teachers in a group.by taheito at 2012-11-19 13:32:55
[quote="kittH"]Your initial query gets all of the groups named "* Teachers" in the Schools OU. You then run a foreach loop for each of those groups.by taheito at 2012-11-19 13:35:02
The first two items in the loop run the same query that generated the group list. Inside each loop you’re getting all of the users in all of the groups.
Try changing the lines to:
$u = $_ | Get-QADGroupMember
$f = $_ | Get-QADGroupMember | get-qaduser -NotLoggedOnFor 47 -SizeLimit 0 -PageSize 2000[/quote]
Hello kittH,
thanx allot for your help it’s working now well
[quote="ArtB0514"]There’s no need to use -SizeLimit or -PageSize on this Get-QADuser unless there are more than 1,000 teachers in a group.[/quote]
Hello ArtB0514
there are some groups that has more 1000 user