Help with powershell script

Welcome Forums General PowerShell Q&A Help with powershell script

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

 
Participant
9 months, 2 weeks ago.

  • Author
    Posts
  • #93072

    Participant
    Points: 0
    Rank: Member

    Can someone please help me with the following? I need to create a script that compares Get-WMIObject win32_userprofile against Get-ADuser. If the user profile name isn't disabled or does not appear in AD i simply want to remove them from the local machine. How can i filter out the disabled/none accounts in AD and loop through them? At that point i will make a switch that offers to remove them

  • #93082
    Jon

    Participant
    Points: 27
    Rank: Member

    If you need a list of disabled AD accounts you can do this, then select samaccountname or whatever property you want to go off of.

    get-aduser -filter {Enabled -eq $false}
  • #93088

    Participant
    Points: 165
    Helping Hand
    Rank: Participant

    What kind of help do you need? To find diabled AD accounts you can use

    Search-ADAccount -AccountDisabled -UsersOnly

    To delete local profiles I would recommend to use delprof2 – IMHO the standard tool for this task for many years.

The topic ‘Help with powershell script’ is closed to new replies.