5

我想在我的 Azure 部署中安装 IP 和域限制功能,但我使用的 os 版本 3(Server 2012)已经贬低了 ServerManageCmd,因此以下代码不起作用:

启动任务.cmd

@echo off

@echo Installing "IPv4 Address and Domain Restrictions" feature 
%windir%\System32\ServerManagerCmd.exe -install Web-IP-Security

@echo Unlocking configuration for "IPv4 Address and Domain Restrictions" feature 
%windir%\system32\inetsrv\AppCmd.exe unlock config -section:system.webServer/security/ipSecurity

ServiceDefinition.csdef 部分

<Startup>
      <Task commandLine="Startup\StartupTasks.cmd" executionContext="elevated" taskType="simple" />
</Startup>

我相信我需要使用 powershell 命令,但我在这里有点超出我的深度。任何人都可以提供此代码的 2012 等效项吗?

4

1 回答 1

10

对于那些在家玩的人,这就是答案!

@echo off

@echo Installing "IPv4 Address and Domain Restrictions" feature 
powershell -ExecutionPolicy Unrestricted -command "Install-WindowsFeature Web-IP-Security"

@echo Unlocking configuration for "IPv4 Address and Domain Restrictions" feature 
%windir%\system32\inetsrv\AppCmd.exe unlock config -section:system.webServer/security/ipSecurity
于 2013-07-11T07:21:11.173 回答