Options
Batch file for creating home directories?
ladiesman217
Member Posts: 416
in Off-Topic
Any one who knows how to write a batch file for creating home folders pointed to shared drive on file server?
No Sacrifice, No Victory.
Comments
-
Optionsblargoe Member Posts: 4,174 ■■■■■■■■■□Need more info... Which platform? Windows? with Active Directory? Linux?
If you're using Active Directory, you can simply select all of the user accounts, open the properties, and change all the profiles at once - set the "home folder" to \\servername\sharename\%username%IT guy since 12/00
Recent: 11/2019 - RHCSA (RHEL 7); 2/2019 - Updated VCP to 6.5 (just a few days before VMware discontinued the re-cert policy...)
Working on: RHCE/Ansible
Future: Probably continued Red Hat Immersion, Possibly VCAP Design, or maybe a completely different path. Depends on job demands... -
Optionsladiesman217 Member Posts: 416Need more info... Which platform? Windows? with Active Directory? Linux?
If you're using Active Directory, you can simply select all of the user accounts, open the properties, and change all the profiles at once - set the "home folder" to \\servername\sharename\%username%
Sorry I forgot to add some details.I'm on a Windows domain and I'm working with lots of home folder creation and I want a batch file to simplify the process. We usually create Home folders (z:drive) for users and point it to a server share using the profiles tab, what I mean is to write a batch file that will create the folders on the server share and point the users z-drive to that folder.
Btw thanks for your input.No Sacrifice, No Victory. -
Optionscrrussell3 Member Posts: 561I used this powershell script to change all of our users home drives during a migration to dfs. I did a query first that found all users who had a home drive set (as to exclude service accounts). I also used the Quest PowerShell commandlets.
Get-QADUser -SizeLimit 0 | Where {$_.HomeDirectory -like "\\*"} | Foreach-Object{ Set-QADUser $_ -HomeDirectory "\\[your_path_here]\$($_.logonname)" -HomeDrive 'H:'} -Whatif
(I added the -WhatIf parameter. Remove this after you have completed testing so it will actually make the changes instead of performing a theoretical change).
You will just need to add something that will actually create the folders for you, as I am not sure if they will be created this way or not (all of mine were existing).MCTS: Windows Vista, Configuration
MCTS: Windows WS08 Active Directory, Configuration -
Optionsblargoe Member Posts: 4,174 ■■■■■■■■■□ladiesman217 wrote: »I mean is to write a batch file that will create the folders on the server share and point the users z-drive to that folder.
Btw thanks for your input.
You're welcome
You don't really have to script the folders ahead of time, if you have rights to create them. When you set the path using the AD Users and Computers console for that user, it will create the folder for you when you click apply and add that user's permissions to the folder for you.IT guy since 12/00
Recent: 11/2019 - RHCSA (RHEL 7); 2/2019 - Updated VCP to 6.5 (just a few days before VMware discontinued the re-cert policy...)
Working on: RHCE/Ansible
Future: Probably continued Red Hat Immersion, Possibly VCAP Design, or maybe a completely different path. Depends on job demands... -
Optionsinstant000 Member Posts: 1,745You're welcome
You don't really have to script the folders ahead of time, if you have rights to create them. When you set the path using the AD Users and Computers console for that user, it will create the folder for you when you click apply and add that user's permissions to the folder for you.
this is what I was thinking when I saw this question.
There is a Home drive attribute, and also an attribute that points to the folder location of the user.
Just set it to something like \\file01\shared_folder\%username%
EDIT: Since it's an attribute, you can just script in adding this attribute across all your users, and it will fix all your current users.
Then, just add this to your user creation script program, and you're good to go for any users made in the future.Currently Working: CCIE R&S
LinkedIn: http://www.linkedin.com/in/lewislampkin (Please connect: Just say you're from TechExams.Net!) -
Optionsazjag Member Posts: 579 ■■■■■■■□□□ladiesman217 wrote: »Sorry I forgot to add some details.I'm on a Windows domain and I'm working with lots of home folder creation and I want a batch file to simplify the process. We usually create Home folders (z:drive) for users and point it to a server share using the profiles tab, what I mean is to write a batch file that will create the folders on the server share and point the users z-drive to that folder.
Btw thanks for your input.
Forgive my ignorance. Is this during the account creation or something that is happening after the fact? If it is during account creation then create a template with these settings already in place. If it is after the fact then what Blargoe said is perfect.Currently Studying:
VMware Certified Advanced Professional 5 – Data Center Administration (VCAP5-DCA) (Passed)
VMware Certified Advanced Professional 5 – Data Center Design (VCAP5-DCD) -
Optionsladiesman217 Member Posts: 416thanks for the input guys.
What we actually do is creating home folders for existing user accounts, it's really a long process drilling down to the share and creating the folders manually and then set the user's profile home folder to point to the newly created folder. What I want to come up with is a batch file that would create the folder in the server share and point the users home folder to that path and assign the modify permission for the user.
This is what I've got from Microsoft's site
md c:\users\<username>
rmtshare \\<HomeServer>\<username>$=c:\users\<username>
/grant <username>:f /grant administrator:f
/remove everyone
Batch Process to Create and Grant Access to Home Directories
I'm really new to scripting so does anyone how to modify this one or maybe come up with something better. ThanksNo Sacrifice, No Victory. -
OptionsRobertKaucher Member Posts: 4,299 ■■■■■■■■■■You shoulld really be looking at crrussel3's approach to this with PowerShell.
If you are a Windows admin then learning how to do stuff via a "batch file" is like learning how to configure Windows 2000. PowerShell will only help you as time goes on, since every single MS server app and OS is now integrated with PowerShell.