Quantcast
Channel: Software Communities : Popular Discussions - ActiveRoles
Viewing all articles
Browse latest Browse all 1277

Help With Powershell Script - Create Folders Within homeDirectory

$
0
0

Hello,

 

New to scripting and trying my best to learn what I can but I've hit a wall and need to ask for assistance.  I'm trying to create two folders within a users homeDirectory.  Not sure if this can be done but I'd like to attach a script policy to a specific OU within Active Directory that runs when a new user gets created within that particular OU. I've read that Group Policy would be an easier way to go about doing this which I would agree with but these specific folders need to be created before the user logs in.

 

Here's what I've been able to come up with thus far:

 

function onPostCreate{$Request}

{

if{$Request.Class -ne "user"}{return}

 

$homeDir=$Request.Get{"homeDirectory"}

 

New-Item -Path $homeDir -Name "Folder1" -ItemType Directory

New-Item -Path $homeDir -Name "Folder2" -ItemType Directory

}

 

I'll create the user which creates the home directory share on the specified server (set in the user creation policy) but these subfolders aren't being created.

 

I appreciate any help with this.


Viewing all articles
Browse latest Browse all 1277

Trending Articles