[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2715
  • Last Modified:

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.
0
Pete
Asked:
Pete
  • 2
  • 2
2 Solutions
 
Chris DentPowerShell DeveloperCommented:

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

Chris
0
 
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.
0
 
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?
Thanks
 

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

0
 
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"

Chris
0

Featured Post

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now