Help with powershell script

This topic contains 2 replies, has 3 voices, and was last updated by  Olaf Soyk 3 months, 2 weeks ago.

  • Author
  • #93072


    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


    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

    Olaf Soyk

    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.

You must be logged in to reply to this topic.