0

how to Get Success/Failure Response from PowerShell Enable/Disable User using following scripts.I need to update the status of the user.

Get-ADUser -Filter mail -eq $mail | Disable-ADAccount
Get-ADUser -Filter 'mail -eq "[email protected]"' | Enable-ADAccount 

Please advice me to resolve this.

1 Answer 1

2

just add the -passthru parameter to the enable-Adaccount and that will pass the user object along with all its properties. You then want to select the enabled user property.

Get-ADUser -Filter 'mail -eq "[email protected]"' | 
    Enable-ADAccount -PassThru | Select-Object Enabled
Sign up to request clarification or add additional context in comments.

2 Comments

Same goes for Disable-ADAccount -PassThru
Working Thanks a Lot

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.