Jump to content

Recommended Posts

Posted

Quick and dirty PS script to remove a single profile or matching pattern of profile names from a single computer or group of computers.

Feel free to add your own validation etc.

 

#Import Active Directory Module

Import-Module -Name ActiveDirectory

 

#get the profile name from the console input:

$input_profile_name = Read-Host -Prompt 'Enter the profile name or pattern ( e.g. test-teacher-* )to delete '

 

#get the computer name from the console input:

$input_computer_name = Read-Host -Prompt 'Enter the computer name to or pattern ( e.g. IT-suite1-* ) to delete the profile from '

 

# Get computers from AD:

Get-ADComputer -Filter 'name -Like $input_computer_name' | Sort-Object | ForEach-Object -Process {

# set the variable $computer_name to the next computer name from the list generated:

$computer_name = $_.Name

# Run delprof2 for each computer:

& '\\someserver\somefolderpath\DELPROF2.EXE' /u /i /id:$input_profile_name /C:\\$computer_name

}

  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...