What is the error message?Does the corresponding folder on the shared folder exist?
Move all homedirectory folders to a new location
TJ Cooper
26
Reputation points
I want to move the homedirectory folder for all users in an OU to a new share. I have this:
$users = get-aduser -Filter * -SearchBase "OU=HDrive_Delete,OU=SC,OU=Disabled Accounts,DC=test,DC=LOC" -Properties SamAccountName,homedirectory,Division
foreach($user in $users)
{
Move-Item "($_.homedirectory)" \\fileserver\DisabledHomeDrives\$_.homedirectory
}
It not working. Should I create two strings, sourcefolder, targetfodler, and then pass that to a robocopy script?
I need to query an OU
Move the folder and append the folder name
Delete the original folder (in the case robocopy is used)
thank you!!!
2 answers
Sort by: Most helpful
-
Young Yang (Shanghai Wicresoft Co,.Ltd.) 661 Reputation points
2020-08-05T07:09:32.307+00:00 -
Young Yang (Shanghai Wicresoft Co,.Ltd.) 661 Reputation points
2020-08-20T01:46:30.76+00:00 Hi, given that this post has been quiet for a while, this is a quick question and answer. Has your question been solved? If so, please mark it as an answer so that users with the same question can find and get help.
:)