Search found 24 matches

by notarat
Tue Aug 27, 2013 5:56 am
Forum: PowerShell
Topic: retrieve multiple values from same query
Replies: 9
Views: 5378

Re: retrieve multiple values from same query

Try it this way: Import-Module ActiveDirectory $groups = Get-ADGroup -f * -searchbase 'MY OU HERE' $results=foreach ($group in $groups){ Write-Host $group.Name -fore green $members=Get-ADGroupMember $group.Name -ea 0 | Get-ADUser -Property * -ea 0 $props=@{ GroupName=$group.name MemberCount=$member...
by notarat
Mon Aug 26, 2013 12:58 pm
Forum: PowerShell
Topic: retrieve multiple values from same query
Replies: 9
Views: 5378

Re: retrieve multiple values from same query

I seem to be receiving a lot of errors when I run the code. The odd thing is, if I manually do the steps, it works Example: $m=Get-ADGroupMember Security_GroupName | Get-ADUser -Property * $m.count PS c:\> 47 $i=($m|?{$_.lockedout -or $_.enabled -like 'false'}).count PS c:\> 27 These numbers are cor...
by notarat
Mon Aug 26, 2013 11:32 am
Forum: PowerShell
Topic: retrieve multiple values from same query
Replies: 9
Views: 5378

Re: retrieve multiple values from same query

So $props allows for the creation and population of multiple items from 1 query? Nice!

I will have to research this (obviously, D'Uh) and see if I can't make my older scripts a bit more efficient.

Thanks a bunch!
by notarat
Mon Aug 26, 2013 11:03 am
Forum: PowerShell
Topic: retrieve multiple values from same query
Replies: 9
Views: 5378

retrieve multiple values from same query

I'm still pretty new at power shell so please be gentle. I'm currently trying to retrieve a listing of all security groups in an OU, count the total members assigned, and also count accounts in a group that are inactive (either locked out or disabled) My current code does that(I think) but it curren...