ChrisS Posted May 25, 2016 Posted May 25, 2016 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 } 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now