0
$GetLockoutStatus = Get-ADUser -Identity $WPFnamelookupbox.Text | Select-Object Enabled
    if($GetLockoutStatus -eq $true){
        $WPFlockedaccount.IsChecked = $true
    }

The issue I have is that the checkbox does not seem to be getting checked. I can run the powershell command manually just fine and it shows that the account is enabled but not happening visually with the checkbox.

Am I missing something obvious here?

Jason
  • 811
  • 1
  • 12
  • 26

1 Answers1

1

By using Select you have an object with just the Enabled property. You can either add that property to your if statement:

if($GetLockoutStatus.enabled -eq $true){

Or you can expand the property first:

$GetLockoutStatus = Get-ADUser -Identity $WPFnamelookupbox.Text | Select-Object -ExpandProperty Enabled

Or you could get the property using ().Enabled

$GetLockoutStatus = (Get-ADUser -Identity $WPFnamelookupbox.Text).Enabled
BenH
  • 9,766
  • 1
  • 22
  • 35