Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ADTimeline.ps1 #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions ADTimeline.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 ; }
Expand Down