primary_key
在这一行中如何检查这些条件?
$lastname = "xyz"
$firstname = "abc"
$username = $lastname_$firstname -or $firstname.$lastname #error
答案 0 :(得分:0)
如果您只是想检查用户名是否存在,则可以测试$aduser
是否不是$null
。
您还需要为可能满足的每个条件指定sAMAccountName -eq
。并且您还需要在过滤器周围加上引号。
$lastname = "xyz"
$firstname = "abc"
$aduser = Get-ADUser -f "sAMAccountName -eq '$($lastname)_$firstname' -or sAMAccountName -eq '$firstname.$lastname'"
if ($aduser -ne $null) {
Write-Host "username exist"
} else {
Write-Host "user doesn't exist"
}
答案 1 :(得分:0)
dim jrePath as string
jrePath = redirect("cmd","/c dir")
jrePath = redirect("where java","")
答案 2 :(得分:0)
我目前无法对此进行测试,但是如果您只有名字和姓氏,则可以执行以下操作:
$aduser = Get-ADUser -filter "(GivenName -eq $firstname) -and (Surname -eq $lastname)"
if ($aduser) {
Write-Host "user exists"
} else {
Write-Host "user doesn't exist"
}
或结合使用$firstname
和$lastname
成为用户的全名,然后尝试以下操作:
$username = "$firstname $lastname"
$aduser = Get-ADUser -filter "Name -eq $username"
if ($aduser) {
Write-Host "user exists"
} else {
Write-Host "user doesn't exist"
}