Solved

change home folder path

Posted on 2016-10-05
4
52 Views
Last Modified: 2016-10-05
dear experts,

I am trying to clean up our AD environment. this is what I would like to achieve:

1) search giving accounts in csv format based on Samaccount name  in AD
2) change user home folder path to "local path"
3) disable the account and move user account to a specific OU called "leavers OU"

could you please help me with a PowerShell code?
0
Comment
Question by:kuzum
  • 2
  • 2
4 Comments
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 41830865
Try..
Import-csv C:\input.csv | %{
 Set-ADUser $_.SamAccountNAme -Enabled $false -homedirectory $null -PassThru  |  
 Move-ADObject -TargetPath "OU=leavers OU,DC=Domain,DC=com"
}

Open in new window

0
 

Author Comment

by:kuzum
ID: 41830890
thanks, Tested it now and it worked but instead of c:\temp can we change it "local Path" under home folder tab  option that is available in AD.  I think you misunderstood me on this. there are two options in account properties;  local path and "connect" I just need Local path tp be selected and left blank. is it possible?
0
 
LVL 40

Expert Comment

by:Subsun
ID: 41830895
I did change the code later when I read your question again after posting my comment... Change C: temp to $null
0
 

Author Closing Comment

by:kuzum
ID: 41830911
excellent work again. thank you. much appreciated.
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MaxPosPhaseCorrection setting 3 19
Exchange 2010 RU 16 5 28
Cant remote powershell into server 3 21
Problem to setup GUI 11 31
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
The viewer will learn how to count occurrences of each item in an array.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question