PowerShell create home directory

Spread the love

Why PowerShell create user directory script?

This PowerShell script creates a home folder for all users in AD  and configures folder permision to ensure that a user can only be accessed by the user.

#####This script has the following functionalities:############################

#1 Creates a personal (home folder) for all AD users
#2 Provides option to create users folders as DisplayName or sAMAccountname (Log on name)
#3 Grants each users “Full Control” to his or her folder
#4 Maps the users folder as drive ‘H’ (Configured via AD Users property)
#5 Ensures that users canot access another user’s folder
#6 Script tested on a Windows Server 2012 R2 and confirmed working

To Download the script and ReadMe text file, click CreatehomefolderforADUsers.ps1

Set up NTFS Permission before running PowerShell create home directory:

Follow the steps below to configure NTFS and share permission the base folder. Users folder will be created in this folder. I tested this script using ‘Users’ folder shared as ‘Users$’:

  1. Right-click Users folder and select properties, click Security tab and configure as shown below: Grant SYSTEM and Domain Admins: FULL CONTROL –
  2. Users_NTFS_Security_Config
  3. Click Sharing tab , and then click Advanced Sharing. Check the box Share this folder, then below Share name, click Add.
  4. Share the folder as Users$ (Hidden share) – Ensures that if a user browses to \\servername, this share is hidden.
  5. Click Permissions and ensure that the share permission is configured as shown below: Everyone: FULL CONTROL.
  6. powershell-create-home-directory

 

DISCLAIMER: This script is published on “As Is” basis. I will not take any responsibility for any damage this script might do to your production or test server environment. Please ensure that you test this properly in a non-production environment before running or scheduling the script in a production environment.


Spread the love

Leave a Reply

Your e-mail address will not be published. Required fields are marked *

By using this website you agree to accept our Privacy Policy and Terms & Conditions