PowerShell script in AD for RESTING PASSWORD

Babylon DJ Sounds -Steve
Babylon DJ Sounds -Steve used Ask the Experts™
on
Hey Guys,

I need help writing a PowerShell script in AD for Removing a User (disable user account\termination.

Where do I start and how? I have 0 PowerShell experience

Here is the steps

Reset password users in Active Directory
Remove all Profile tab option
remove all Profile tab options
remove all organization changes tab (and clear manager name) (SharePoint list)
remove Member Of groups except Domain Users
Remove user from Moble Device In Exchange
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2013
Commented:
You will need RSAT (Remote Server Administration Tools) installed

For starters, import the Active Directory Module into powershell
import-module Active Directory

Open in new window


To change the users password (https://docs.microsoft.com/en-us/powershell/module/addsadministration/set-adaccountpassword?view=win10-ps)

Set-ADAccountPassword -Identity USERNAME -Reset -NewPassword (ConvertTo-SecureString -AsPlainText "PASSWORDHERE" -Force)

Open in new window

To zero out the fields:
#this command populates the a variable with all of the properties for the user account
$user = get-aduser -properties *

Open in new window


to see them all, just call the variable by itself

$user

Open in new window


To change them:

$user.ProfilePath = ''
$user.ScriptPath = ''
$user.HomeDirectory = ''
$user.HomeDirectory = ''
$user.HomedirRequired = $false

Open in new window

Do this to as many of the fields as you want to

once you are finished updating fields in your variable, publish them:

set-aduser -instance $user

Open in new window


to remove all of the users groups:

Get-ADPrincipalGroupMembership USERNAME | ? {$_.name -ne "Domain Users"} | % { Remove-ADGroupMember
$_.name -Members USERNAME}

Open in new window


I no longer have an Exchange Server to test with, so I cannot confirm this, but to remove the user's Mobile devices, the code could look something like this:

Get-ActiveSyncDevice -Identity USERNAME | Remove-ActiveSyncDevice

Open in new window

Thank you. Will try it out and see

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial