?
Solved

change home folder path

Posted on 2016-10-05
4
Medium Priority
?
85 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 2000 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Had a business requirement to store the mobile number in an environmental variable. This is just a quick article on how this was done.
After seeing many questions for JRNL_WRAP_ERROR for replication failure, I thought it would be useful to write this article.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Suggested Courses

752 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