Powershell禁用匿名FTP并启用身份验证

时间:2020-01-22 16:48:29

标签: powershell iis ftp

尝试在PowerShell中做相当简单的事情。在默认的ftp站点上禁用匿名FTP并启用基本身份验证,例如:FTP Authentication

这就是我要尝试的:

c:\windows\system32\inetsrv\appcmd unlock config /section:anonymousAuthentication
c:\windows\system32\inetsrv\appcmd unlock config /section:basicAuthentication
Set-WebConfigurationProperty -filter /system.webServer/security/authentication/anonymousAuthentication -name Enabled -value false -PSPath 'IIS:\sites\Default FTP Site\'
Set-WebConfigurationProperty -filter /system.webServer/security/authentication/basicAuthentication -name Enabled -value true -PSPath 'IIS:\sites\Default FTP Site\'

此操作成功完成:

Unlocked section "system.webServer/security/authentication/anonymousAuthentication" at configuration path "MACHINE/WEBROOT/APPHOST".
Unlocked section "system.webServer/security/authentication/basicAuthentication" at configuration path "MACHINE/WEBROOT/APPHOST".

但是它对实际的IIS配置完全没有影响。我想念什么?

1 个答案:

答案 0 :(得分:0)

请尝试此命令行。它将禁用匿名身份验证并启用基本身份验证。只需记住以管理员身份运行powershell。

Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST'  -filter "system.applicationHost/sites/site[@name='Default FTP Site']/ftpServer/security/authentication/anonymousAuthentication" -name "enabled" -value "False"
Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST'  -filter "system.applicationHost/sites/site[@name='Default FTP Site']/ftpServer/security/authentication/basicAuthentication" -name "enabled" -value "True"