gpt4 book ai didi

asp.net - 在 Windows Server 2012 的 Azure 启动任务中安装功能

转载 作者:行者123 更新时间:2023-12-04 17:22:46 24 4
gpt4 key购买 nike

我想在 Azure 部署中安装 IP 和域限制功能,但我使用的是操作系统版本 3 (Server 2012),该版本已弃用 ServerManageCmd,因此以下代码不起作用:

StartupTask.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 等效版本吗?

最佳答案

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

@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

关于asp.net - 在 Windows Server 2012 的 Azure 启动任务中安装功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17586495/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com