Solved

change home folder path

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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Utilizing an array to gracefully append to a list of EmailAddresses
Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
The viewer will learn how to count occurrences of each item in an array.
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…

910 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

18 Experts available now in Live!

Get 1:1 Help Now