Solved

change home folder path

Posted on 2016-10-05
4
39 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
Synchronize a new Active Directory domain with an existing Office 365 tenant
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

758 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now