Powershell -NotLIke comparison -


as newbie in powershell made following script:

get-aduser -searchbase "ou=bel,ou=eu,dc=domain,dc=net" -filter * -properties * |     {$_.cn -notlike ***$_.l***} |     select whencreated, name,displayname, sn,  givenname, samaccountname, title,         description, employeetype, info, department, company, homedirectory,         scriptpath, physicaldeliveryofficename,          @{label='manager';expression={             (get-aduser $_.manager -properties displayname).displayname}} |     export-csv "output.csv" -notypeinformation -delimiter ";" -encoding utf8  start "output.csv" 

as result see users don't have city (l) mentioned in cn (name) field. example result be:

cn : john (denver) usa l: oklahoma

for 1 reason or sript works doesn't compare city mentioned in 'l'. gives me users in ad, , when passing wildcards powershell doesn't seem use them.. advise great. thank already.

i don't know why have 3 asterisks surrounding $_.l. should 1 of following:

where {$_.cn -notlike "*$($_.l)*"} {$_.cn -notlike "*" + $_.l + "*"} {$_.cn -notlike ("*{0}*" -f $_.l)} 

or use -notmatch:

where {$_.cn -notmatch $_.l} 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -