i attempting grab samaccountname sip address attribute in ad. keep getting syntax error can't figure out. have used similar code grab samaccountname using employeenumber attribute. have wonder if "-" in attribute name has syntax error.
import-csv -path .\sip.csv | foreach-object { $sipget = get-aduser -filter "msrtcsip-primaryuseraddress -eq $($_.'msrtcsip-primaryuseraddress')" | select -expand samaccountname $_ | select *,@{name='samaccountname';expression={$sipget}} } | export-csv -path .\sip.csv -notypeinformation any appreciated!
get-aduser not know -eq filter. instead, use plain equal sign, , wrap string in escaped double quotes.
$sipget = get-aduser -filter "msrtcsip-primaryuseraddress = \"$($_.'msrtcsip-primaryuseraddress')\"" | select -expand samaccountname should do. (can't test right now, have no access ad environment)
Comments
Post a Comment