how to get value of accountenabled

Hi I want to check if a useraccount in AD is enabled or disabled

[pre]

#Install-Module -name azuread
Connect-AzureAD
$Account = "user@mail.com"
$value ="False"
$accountEnabled =get-azureADUser -objectid $Account | select accountEnabled
if ($accountEnabled -eq $value){
Write-Host "please continue"
}
else {
write-host "exit script"
}
[/pre] when I run the above script it gives me as output "exit script" when I run $accountEnabled I get this as output AccountEnabled -------------- False how do I capture the value "False" here?
Paul

Hello acer460527,

On line #6 at the end before account enabled add -ExpandProperty and it will work:

$accountEnabled=Get-AzureADUser -objectID $Account | select-object -ExpandProperty accountEnabled

Hope that helps.

 

thanks Andy this works

best regards

Paul