get-qaduser -samaccountname $samname
is a search for users with a specific samAccountName, it can return
several users and it shouldn't return an error if it has found none.
OTOH,
get-qaduser $identity
is a bind attempt and it will throw if none or more than one user is
found. $identity can be specified in many ways (read the docs or
output of get-help get-qadUser -full for full list). For example,
valid values for Identity are
domainNetbiosName\accountName and user principal name so you can use
something like this:
get-qaduser "domainNetbiosName\" + $samname
or
get-qaduser $samname + "@domain.dns.name"
You can even specify exactly the type of Identity (so the cmdlet won't
have to analyze the value of Identity param) using the disambiguation
prefix (advanced and probably underdocumented feature):
get-qaduser "account=domainNetbiosName\accountName"
get-qaduser "upn=accountName@domain.dns.name"
BTW, if you just want to compare contents of CSV file with the
contents of some OU you can just do this:
$diff = Compare-Object $(import-csv sample.csv) $(Get-QADUser -ou
domain.dns.name/myOu) -property DN
This assumes you have a DN column in CSV, but you can use another
property.
And one more thing: you can post questions related to Quest cmdlets (*-
qad*) to the following forum:
http://www.powergui.org/forum.jspa?forumID=173
This is the support forum for the Quest AD mgmt snapin and is
monitored by the developers of this snapin (myself included).
HTH