I have folder called userdata.
Within the userdata folder are the users home drives. The folder name is the same as their user account name:
ataylor and so forth. (1000's)
We are robocopying user data from one server to another. I need to recreate the share once it has moved and apply the permissions.
I'd really like to use powershell to do this.
I have this thus far (taken from http://social.technet.microsoft.com/Forums/windowsserver/en-US/3edcabac-f1a8-4c4a-850c-8ba4697930a2/using-net-share-within-powershell
but its not working, please help
#Get a list of the user folders and the path
$users=get-childitem C:\ain\userdata\ -name ; $SrvPath = "C:\ain\Userdata\"
#Create a scrptblock with the Net SHARE COMMAND
$sb = `
NET SHARE $User=$SrvPath+$user "/GRANT:Domain\Domain Admins,FULL" "/GRANT:DOMAIN\+$User,CHAN
GE" /REMARK:"Home folder for $SrvPath"
Invoke-Command -ScriptBlock $sb -ArgumentList $user,$SrvPath
NET : System error 1332 has occurred.
+ NET SHARE $User=$SrvPath+$user "/GRANT:Domain\Domain Admins,FULL" "/GRANT:DOMAI ...
+ CategoryInfo : NotSpecified: (System error 1332 has occurred.:String) , RemoteException
+ FullyQualifiedErrorId : NativeCommandError
No mapping between account names and security IDs was done.