Set msIIS-FTPDir, msIIS-FTPRoot using PowerShell

I am setting up User Isolated FTP and want to set msIIS-FTPDir, msIIS-FTPRoot values for all my win2003 users (1300 of them).

FTPRoot - \\server\Users
FTPDir - \username (or \%a)

Can I script this in PowerShell. I really want to run this powershell script as a scheduled task so new users can be edited with these values automatically every now and again.
Who is Participating?
PeteAuthor Commented:
I have done a script, first ccommand exports all users without ftproot and dir vaues to a csv, the second makes the change for those users. The thing is it will edit EVERY user inclding all the builtin accounts, admin, IUSR etc etc - does this matter?
Maybe I could edit the script to ignore the BUILTIN or USER OU's? Can anyone offer any advice?

The first command is:

Get-QADUser -LdapFilter "(!(msiis-ftpdir=*))" `
  -IncludedProperties "sAMAccountName" | `
Select-Object Name, "sAMAccountName" | `
Export-CSV "C:\csv.csv"

And the second is:
import-csv "C:\csv.csv" | 
    $u =  get-qaduser -Identity $_.samaccountname
    $ftproot = "\\server\users"
    set-qaduser $u -ObjectAttributes @{"msiis-ftproot"=$ftproot}
    set-qaduser $u -ObjectAttributes @{"msiis-ftpdir"=$_.samaccountname}

Open in new window

Chris DentPowerShell DeveloperCommented:

I see no problem with that. Are you wanting to use the Quest CmdLets? Or native PowerShell?

PeteAuthor Commented:
I don't really mind if I use quest or native powershell, whichever gives the simplest script I suppose. I am quite new to powershell. It also needs to work with the imminent 2008 upgrade.
I have been using 'FTP User Editor for Microsoft Active dir' program but it has it's limitations.
Chris DentPowerShell DeveloperCommented:

You might benefit from setting a SearchRoot for Get-QADUser (in addition to the filter). That will work very well if the users you're interested in modifying are beneath a single OU (including sub-OUs of that).

Personally I have an OU called "Offices", beneath that each office, and (eventually) beneath that user accounts. So I would use:

Get-QADUser -LdapFilter "(!(msiis-ftpdir=*))" -SearchRoot "OU=Offices,DC=domain,DC=com"

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.

All Courses

From novice to tech pro — start learning today.