Add a Attribute for a User Name in AD

Posted on 2013-10-01
Medium Priority
Last Modified: 2013-10-01

I have created a script that creates a user and updates the following user attributes :

- msIIS-FTPDir
- msIIS-FTPRoot

What I would like to do, is to use the $NewFTPUser to be aded to the value of msIIS-FTPDir, for example, I create a user RCaussy, this is help in the $NewFTPUser variable. Then I would like to have the msIIS-FTPDir to have the same value 'E:\<new user>'.

The script below is what I am working on :

$NewFTPUser = read-host "What is the login name"

New-ADUser $NewFTPUser -AccountPassword (read-host -AsSecureString "Type in the user's password") `
    -PasswordNeverExpires $true `
    -Path "OU=Test,DC=Test,DC=local" `
    -DisplayName $NewFTPUser `
    -UserPrincipalName $NewFTPUser@test.local `
    -ChangePasswordAtLogon $false `
    -CannotChangePassword $false `
    -OtherAttributes @{'msIIS-FTPRoot'= 'E:\'; 'msIIS-FTPDir' = 'E:\SFTPRoot\Commercial'} `
    -Enabled $true

I have tried   -OtherAttributes @{'msIIS-FTPRoot'= 'E:\' + $NewFTPUser but to no avail.
Question by:CaussyR
LVL 42

Accepted Solution

footech earned 2000 total points
ID: 39536565
Sorry I haven't tried this yet, but I would try
-OtherAttributes @{'msIIS-FTPRoot'= "E:\$NewFTPUser"; 'msIIS-FTPDir' = 'E:\SFTPRoot\Commercial'} `

Open in new window

or define the variable beforehand and then use that for -OtherAttributes
$ftpRoot = "E:\$NewFTPUser"
  -OtherAttributes @{'msIIS-FTPRoot'= "$ftpRoot"; 'msIIS-FTPDir' = 'E:\SFTPRoot\Commercial'} `

Open in new window


Author Closing Comment

ID: 39536677
Your second option worked - thank you very much.

Featured Post

Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

I’m willing to make a bet that your organization stores sensitive data in your Windows File Servers; files and folders that you really don’t want making it into the wrong hands.
The article explains the process to deploy a Self-Service password reset portal I developed a few years ago. Hopefully, it will prove useful to someone.  Any comments, bug reports etc. are welcome...
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Loops Section Overview

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question