Add a Attribute for a User Name in AD


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.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CaussyRAuthor Commented:
Your second option worked - thank you very much.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.