从CSV代理地址powershell获取sAMAccountNames

时间:2016-10-19 13:43:39

标签: powershell csv foreach

我在文件中的值是在SMTPproxyaddresses标题下。所以,我正在尝试这方面的事情。

location.replace("/other_page.html")

CSV文件:

foreach ($user in $userID)
{

    $ADuser = Get-ADUser -Filter "ProxyAddress -eq $($user.SMTPproxyaddresses)" -Properties whenCreated, Enabled, SAMAccountName
}

1 个答案:

答案 0 :(得分:0)

I couldn't get it working with a variable inside the Filter parameter, but it worked typed outright. However, the alternative is using an LDAPFilter and this worked for me.

    Get-AdUser -LDAPfilter "(ProxyAddresses=*$($user.SMTPaddresses))" -Properties whenCreated, Enabled, SamAccountName