Solved

change home folder path

Posted on 2016-10-05
4
58 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

Question has a verified solution.

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

Background Information Recently I have fixed file server permission issues for one of my client. The client has 1800 users and one Windows Server 2008 R2 domain joined file server with 12 TB of data, 250+ shared folders and the folder structure i…
Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
This tutorial will walk an individual through the process of installing of Data Protection Manager on a server running Windows Server 2012 R2, including the prerequisites. Microsoft .Net 3.5 is required. To install this feature, go to Server Manager…
The viewer will learn how to count occurrences of each item in an array.

749 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