Skip to content

Commit

Permalink
Update Search-FullNameToSamAccount.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Un1k0d3r authored Oct 24, 2019
1 parent c1b5079 commit 2d5f932
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions scripts/Search-FullNameToSamAccount.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ function Search-FullNameToSamAccount {
[Parameter(Mandatory=$True, ValueFromPipeline=$True)]
[string]$Filter,
[Parameter(Mandatory=$False)]
[string]$Domain = "",
[Parameter(Mandatory=$False)]
[switch]$SamOnly = $False
)

Expand All @@ -17,8 +19,9 @@ function Search-FullNameToSamAccount {
ForEach($User in $Filter) {
Write-Output "[*] Searching for $($User)"
$Query = "(&(objectCategory=User)(displayName=*$($User)*))"
$Domain = New-Object System.DirectoryServices.DirectoryEntry

if($Domain -eq "") {
$Domain = New-Object System.DirectoryServices.DirectoryEntry
}
$DirSearch = New-Object System.DirectoryServices.DirectorySearcher
$DirSearch.SearchRoot = $Domain
$DirSearch.PageSize = 100
Expand Down

0 comments on commit 2d5f932

Please sign in to comment.