【问题标题】:Set permissions and settings on IIS FTP site using PowerShell使用 PowerShell 在 IIS FTP 站点上设置权限和设置
【发布时间】:2014-06-24 17:04:09
【问题描述】:

我是 PowerShell 的初学者,我尝试了这个脚本并且运行良好,但我需要将 FTP 授权规则更改为“所有用户”(读、写)并将“FTP 用户隔离”更改为“用户名目录”。

##    NEEDED FOR IIS CMDLETS
Import-Module WebAdministration

##    CREATE FTP SITE AND SET C:\inetpub\ftproot AS HOME DIRECTORY
New-WebFtpSite -Name "Default FTP Site" -Port "21" -Force
cmd /c \Windows\System32\inetsrv\appcmd set SITE "Default FTP Site" "-virtualDirectoryDefaults.physicalPath:C:\inetpub\ftproot"

##    SET PERMISSIONS

## Allow SSL connections 
Set-ItemProperty "IIS:\Sites\Default FTP Site" -Name ftpServer.security.ssl.controlChannelPolicy -Value 0
Set-ItemProperty "IIS:\Sites\Default FTP Site" -Name ftpServer.security.ssl.dataChannelPolicy -Value 0

## Enable Basic Authentication
Set-ItemProperty "IIS:\Sites\Default FTP Site" -Name ftpServer.security.authentication.basicAuthentication.enabled -Value $true

## Give Authorization to Administrators and grant "read"/"write" privileges
Add-WebConfiguration "/system.ftpServer/security/authorization" -value @{accessType="Allow";roles="Administrators";permissions=3} -PSPath IIS:\ -location "Default FTP Site"

## Restart the FTP site for all changes to take effect
Restart-WebItem "IIS:\Sites\Default FTP Site"

【问题讨论】:

    标签: powershell iis ftp


    【解决方案1】:

    找了半天终于找到解决办法了

     ##    NEEDED FOR IIS CMDLETS
    Import-Module WebAdministration
    
    ##    CREATE FTP SITE AND SET C:\inetpub\ftproot AS HOME DIRECTORY
    New-WebFtpSite -Name "test" -Port "21" -Force
    cmd /c \Windows\System32\inetsrv\appcmd set SITE "test" "-virtualDirectoryDefaults.physicalPath:C:\inetpub\ftproot"
    
    ##    SET PERMISSIONS
    
         ## Allow SSL connections 
    Set-ItemProperty "IIS:\Sites\test" -Name ftpServer.security.ssl.controlChannelPolicy -Value 0
    Set-ItemProperty "IIS:\Sites\test" -Name ftpServer.security.ssl.dataChannelPolicy -Value 0
    
         ## Enable Basic Authentication
    Set-ItemProperty "IIS:\Sites\test" -Name ftpServer.security.authentication.basicAuthentication.enabled -Value $true
    ## Set USer Isolation
     Set-ItemProperty "IIS:\Sites\test" -Name ftpserver.userisolation.mode -Value 3
    
    #Set-ItemProperty "IIS:\Sites\test" -Name ftpServer.security.userIsolation. -Value $true
    
         ## Give Authorization to All Users and grant "read"/"write" privileges
    Add-WebConfiguration "/system.ftpServer/security/authorization" -value @{accessType="Allow";roles="";permissions="Read,Write";users="*"} -PSPath IIS:\ -location "test"
    ## Give Authorization to All Users using CMD
    #appcmd set config %ftpsite% /section:system.ftpserver/security/authorization /+[accessType='Allow',permissions='Read,Write',roles='',users='*'] /commit:apphost 
    
         ## Restart the FTP site for all changes to take effect
    Restart-WebItem "IIS:\Sites\test"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-18
      • 2013-02-15
      • 1970-01-01
      相关资源
      最近更新 更多