forked from officecigar/windows_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFind-Multi-UserID-info.ps1
64 lines (40 loc) · 1.7 KB
/
Find-Multi-UserID-info.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<#
.SYNOPSIS
Think powershell think Mr-ITpro.com !!! FUN STUFF
.EXAMPLE
'one', 'two', 'three' TonyB_default.ps1
.EXAMPLE
TonyB_default.ps1 -computername localhost
.EXAMPLE
TonyB_default.ps1 -computername one, two, three
.EXAMPLE
get-content <Somelist.txt> or <anylist.csv> | TonyB_default.ps1
.PARAMETER computername
one or more computername, or IP address... peace to America!
.LINK
http://www.mr-itpro.com
#>
[CmdletBinding(HelpURI='http://google.com')]
Param(
[Parameter(Mandatory=$true,ValuefromPipeline=$true, HelpMessage="Please enter the Server name or IP address you want to view info about")]
[string []]$adusers,
[string]$errorlogpath ='c:\temp\ManyUsersToFind_error_.log'
)
begin{
$host.UI.RawUI.WindowTitle = "Search users in your Domain "
Write-Host ""
import-Module ActiveDirectory
$starttime =Get-Date
}
process{
foreach ($aduser in $adusers) {
#Get-ADUser -filter "name -like '$aduser'" -Properties SamAccountName , givenname, surname, Department, title, department }
#Get-ADUser -filter "name -like '$aduser'" | select SamAccountName , givenname, surname, Department, title, department
Get-ADUser -filter "name -like '$aduser*'" -Properties SamAccountName , Department, DistinguishedName
}
}
End{
$endtime =Get-Date
$total= $endtime -$starttime
Write-host "Total Script time to run $total" -ForegroundColor Yellow |ft -AutoSize
}