Hi Richs,
Thanks for your help, my script is working fine now.
I am really happy with it
Grtz Fabian
"phaldmmor" <Phaldmmor@community.nospam> wrote in message
news:5F68D66E-9CC4-4898-8FA5-13548379030E@microsoft.com...
>I want try to find users with a specific server name in the homedirectory
>in my Active Directory.
> Tryed servel scripts, but none of them seem to work and I can't get
> figured out what is wrong.
> Result are that not 1 single user is found, but I am sure they are there.
>
> Scripts I tryed are :
>
> # Define root
> $root = New-Object DirectoryServices.DirectoryEntry
> 'LDAP://ortec.intranet/DC=ortec;DC=intranet'
>
> # Now create a searcher and set base to base of user Container
> $Searcher = New-Object DirectoryServices.DirectorySearcher
> $Searcher.SearchRoot = $root
>
> #Now find all users and display them
> $users= $searcher.findall()
> Write-Host "There are $($users.count) users in the $($root.name) container
> in ORTEC:`n"
>
> foreach ($user in $users){
> $up=$user.properties
> if ($up.properties -contains "gd")
> {Write-Host "User: $($up.name) `nHomedirectory:
> $($up.homedirectory)`n"}
> else {Write-Host "No Mach"}
> }
>
> And an other script I have tryed :
>
> # Define root
> $Root = New-Object DirectoryServices.DirectoryEntry
> 'LDAP://ortec.intranet/DC=ortec;DC=intranet'
>
> # Now create a searcher and set base to base of user Container
> $Searcher = New-Object DirectoryServices.DirectorySearcher
> $Searcher.SearchRoot = $root
>
> #Now find all users and display them
> $users= $searcher.findall() | where {$_.properties.homedirectory -contains
> "\\gdfile1"}
> Write-Host "There are $($users.count) users in the $($root.name) container
> in ORTEC:`n"
>
> foreach ($user in $users){
> $up=$user.properties
>
> #only do it for users...
>
> if ($user.homedirectory -contains "\\gdfile1"){
>
> Write-Host "User: $($up.name) `nDN: $($up.distinguishedname)`n"
> }
> }
>
>
>



