简体   繁体   中英

Powershell to get the list of disabled users

I'm running this command to get the list of all the disable users but it'S not working

Get-ADUser -Filter (enabled -ne $true)

Here is the error message :

The term 'enabled' is not recognized as the name of a cmdlet, function, script
file, or operable program. Check the spelling of the name, or if a path was inc
luded, verify that the path is correct and try again.
At line:1 char:28
+ Get-ADUser -Filter (enabled <<<<  -ne $true)
    + CategoryInfo          : ObjectNotFound: (enabled:String) [], CommandNotF
   oundException
    + FullyQualifiedErrorId : CommandNotFoundException

You need to use a scriptblock to define the filter. The parantheses are used for "groups" to make sure that the expression inside it invoked before running the cmdlet, which is wrong here as enabled doesn't mean anything to powershell by itself.

Get-ADUser -Filter { enabled -ne $true }

Search-ADAccount cmdlet只有一个参数:

Search-ADAccount -AccountDisabled

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM