Link to home
Start Free TrialLog in
Avatar of Neptune IT
Neptune ITFlag for United States of America

asked on

PS script to obtain "password never expire"

Hi,
I am trying to run a PS script to get All the ad users in specific OU with Password set to never expire. Following is the script that i wrote however i also would like to add the "description" field in the output. I tried with following but the description comes out as blank,even though specific object does have description. Also if any way i can organize regular account vs service account.

Search-ADAccount -PasswordNeverExpires -SearchBase 'OU=Canada,DC=slbntdom,DC=neptunetg,DC=com' | Select-Object name, DistinguishedName, Description
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of oBdA
oBdA

Forgot the SearchBase:
Search-ADAccount -PasswordNeverExpires -SearchBase 'OU=Canada,DC=slbntdom,DC=neptunetg,DC=com' | Get-ADUser -Property Description | Select-Object Name, DistinguishedName, Description 

Open in new window


Shaun,
it's, well, "bad style" (that is, additional and easily avoidable load on the DCs) to retrieve all properties of a user, only to throw away most of them immediately afterwards.
I could have posted the exact same script as you and you would still have found an issue with it :P
Maybe, maybe not ...
Avatar of Neptune IT

ASKER

Thank you guys