Hi I want to check if a useraccount in AD is enabled or disabled
[pre]
Hi I want to check if a useraccount in AD is enabled or disabled
[pre]
Expand it while saving to variable like this
Select -expandproperty accountenabled
or reference the property after storing as you did previously.
$accountenabled.accountenabled
Hi
thanks for that, it still gives me “exit script” as output
when I ask the content of $accountEnabled the value is False
[pre]
$accountEnabled =get-azureADUser -objectid $Account | select -ExpandProperty accountEnabled
[/pre]
any thoughts on how to capture the $value =“False” correctly in the if statement?
Since “accountEnabled” already is a boolean you can use this in your if statement:
$Account = get-azureADUser -objectid ‘user@mail.org’
if ($Account.AccountEnabled) {
Write-Host ‘please continue’
}
else {
write-host ‘exit script’
}
@Olaf
in this scenario the code will proceed when the account is enabled right? so If I want to change this then I would need to
[pre]
if(!($Account.accountEnabled)) {
write-host “please continue”
}
else {
write-host “exit script”
}
[/pre]
Ah … yes. Right.
Sorry I got this wrong …
no worries thanks for your help
You asked how to capture the value false. I gave you the exact answers, yet you say.
Which is precisely what you just said with “the content of $accountenabled is false”. What do you mean capture it as false correctly. What am I missing?