diff --git a/ADTimeline.ps1 b/ADTimeline.ps1 index 1db5adc..8aca773 100755 --- a/ADTimeline.ps1 +++ b/ADTimeline.ps1 @@ -9,13 +9,20 @@ # customgroups can also be an array, in case you import the list from a file (one group per line) # PS>$customgroups = get-content customgroups.txt # PS>./ADTimeline -customgroups $customgroups +# Use parameter groupslike to search for groups using "like" instead of exact match operator +# Note that the names will be automatically surrounded by '*' +# PS>./ADTimeline -customgroups "admin" +# -> will use a search filter { Name -eq "admin" } +# PS>./ADTimeline -customgroups "admin" -groupslike +# -> will use a search filter { Name -like "*admin*" } # Use parameter nofwdSMTP in a large MSExchange organization context with forwarders massively used. # PS>./ADTimeline -nofwdSMTPaltRecipient Param ( [parameter(Mandatory=$false)][string]$server = $null, [parameter(Mandatory=$false)]$customgroups = $null, -[parameter(Mandatory=$false)][switch]$nofwdSMTP +[parameter(Mandatory=$false)][switch]$nofwdSMTP, +[parameter(Mandatory = $false)][switch]$groupslike = $False ) if($customgroups) @@ -2158,7 +2165,16 @@ if($groupscustom) foreach($grpcustom in $groupscustom) { Write-Output "Searching for group(s) '$grpcustom' ..." - try { $grpcs = get-adobject -filter {Name -eq $grpcustom} -server $server -properties * } + try { + if ($groupslike) { + Write-Output "Searching for group(s) '*$($grpcustom)*' ..." + $grpcs = get-adobject -filter { Name -like "*$($grpcustom)*" } -server $server -properties * + } + else { + Write-Output "Searching for group(s) '$grpcustom' ..." + $grpcs = get-adobject -filter { Name -eq $grpcustom } -server $server -properties * + } + } catch { Write-Output "Error while retrieving group(s) '$grpcustom' : $_" { "$(Get-TimeStamp) Error while retrieving group(s) '$grpcustom' : $_" | out-file $logfilename -append ; }