Quantcast
Channel: PowerShell General
Viewing all articles
Browse latest Browse all 10624

Excluding selections

$
0
0

I have been writing a script to collect info from AD, namely groups and their members.

The script works...Smile...but it gives me more info than I need. What I want to acheive is to exclude the Domain Users group from the collection.

This is the script without my attempts to exclude the "Domain users" group.

$DT = Get-Date -UFormat "%Y%m%d_%H%M"
$GroupInfo = '' | Select 'Group Name','Group Description','Member Name','Member Description'
$AllGroups = @()
$MyGroups = Get-QADGroup -DontUseDefaultIncludedProperties  -IncludedProperties Name,Description,Member | select Name,Description,Member
foreach($Group in $MyGroups){
$GroupInfo.'Group Name' = $Group.Name
$GroupInfo.'Group Description' = $Group.Description
foreach($Member in $Group.Member){
$User = Get-QADUser $Member -DontUseDefaultIncludedProperties -IncludedProperties Name,Description | select Name,Description
$GroupInfo.'Member Name' = $User.Name
$GroupInfo.'Member Description' = $User.Description
$GroupInfo | select 'Group Name','Group Description','Member Name','Member Description'
$AllGroups += $GroupInfo | Select 'Group Name','Group Description','Member Name','Member Description'
}
}
#Export all that group info to csv file.
$AllGroups | Export-Csv C:\POSH_Dump\AD-GroupUsers_$DT.csv -NoTypeInformation

 

Need a hand with this as I have tried with -ne and -notlike but unable yet to acheive the exclusion I need.

Any ideas???

Thank you!!!


Viewing all articles
Browse latest Browse all 10624

Trending Articles