Quantcast
Channel: Windows PowerShell Forum
Viewing all articles
Browse latest Browse all 2314

Powershell Active Directory | Search for Attribute Script no Output

$
0
0

Hi guys, 

I am currently working on a script, which searches different attributes in Active Directory and gives me the results in the console or into a text file. 

That's my actual Code: 

$Number = Read-Host -Prompt "Please enter Telephoner number"
Write-Host "Searching in Active Directory......"

Write-Host "You are searching for    $Number     "

get-aduser -filter {Telephonenumber -like "*$Number*" -OR facsimileTelephoneNumber -like "*$Number*" -OR Officephone -like "*$Number*"} -searchbase "ou=NY,ou=DE,OU=!Accounts,ou=!OU,dc=int,dc=domain-now,dc=com" -properties *|select displayname, givenname, sn, telephonenumber

As far as I enter a number like 500 instead of 3x $Number into "*xx*" 
I am getting something like

displayname                         givenname       sn          telephonenumber   
-----------                              ---------          --          ---------------   
Magdalena, Maria                 Maria                 Magdalena      +12 3456789-500

But if try to execute this script with the same number, it just shows nothing. 

What am I doing wroing? 

Best regards

Daniel


Viewing all articles
Browse latest Browse all 2314


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>