Finding and modifying users with passwordneverexpires set to true

Welcome Forums General PowerShell Q&A Finding and modifying users with passwordneverexpires set to true

This topic contains 2 replies, has 2 voices, and was last updated by

 
Participant
4 years, 8 months ago.

  • Author
    Posts
  • #15572

    Participant
    Points: 0
    Rank: Member

    Hello,

    I am relatively new to Powershell and having issues. I am attempting to find all users with passwordneverexpires set to true (who match other criteria like being enabled accounts, non service accounts, etc) and then change the setting to false. Attached is a script that I am trying to use to accomplish the task. I discovered that the set-aduser cmdlet does not accept pipeline input for passwordneverexpires. Is there another way to accomplish this. I would also like the accounts that were changed to be dumped into a csv file. Thanks for any assistance.

  • #15579

    Participant
    Points: 0
    Rank: Member

    Try removing the Select-Object cmdlet before the Set-ADUser. The output of Select-Object is System.Management.Automation.PSObject which is not accepted by any parameters on the Set-ADUser cmdlet. Whereas, Get-ADUser returns Microsoft.ActiveDirectory.Management.ADUser, which will be bound to the -Identity parameter when sent through the pipeline to Set-ADUser.

  • #15585

    Participant
    Points: 0
    Rank: Member

    Peter, that was it. The select-object cmdlet was causing the problems. Thank you!

The topic ‘Finding and modifying users with passwordneverexpires set to true’ is closed to new replies.