Get-Aduser -Filter will not accept a variable

There is valuable information in the existing answers, but I think a more focused summary is helpful. Note that the original form of this answer advocated strict avoidance of script blocks ({…}) and AD-provider variable evaluation, but this has been replaced with more nuanced recommendations. tl;dr Get-ADUser -Filter ‘sAMAccountName -eq $SamAc’ Do not quote the … Read more