簡體   English   中英

使用PowerShell在IIS FTP站點上設置權限和設置

[英]Set permissions and settings on IIS FTP site using PowerShell

我是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"

經過長時間的搜索終於找到解決方案了

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM