Quantcast
Channel: /r/powershell – How to Code .NET
Viewing all articles
Browse latest Browse all 8793

IF/Else Get-ADUser

$
0
0

Basically I’m reading from a text file that has usernames in it but I also want to be able to mix in EmployeeIds to also return all the ALL of the PROPERTIES.

By using If/Else I can do a regex… 9 digits equals EIN running the query based on the EIN(1) and if it’s not digits then it would run the username (2). Would REGEX be the best way to do this? Any thoughts?

Sample Text

300002244

300005535

300005535

100713667

matteblue

300008765

bluematte

This one doesn’t return all the properties(1)

$Result-String = Get-ADUser -Properties employeeid -Filter {employeeid -eq $username} -Server bankofmatteblue 

This one returns all of the properties(2)

$Result-String = Get-AdUser $username -Server bankofmatteblue -Properties * 

This is driving me nuts, Thanks in ADVANCE!

submitted by /u/matteblue
[link] [comments]

The post IF/Else Get-ADUser appeared first on How to Code .NET.


Viewing all articles
Browse latest Browse all 8793

Trending Articles