簡體   English   中英

在Windows Server 2012的Azure啟動任務中安裝功能

[英]Installing feature in Azure startup task for Windows Server 2012

我想在我的Azure部署中安裝IP和域限制功能,但我使用的是os版本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 partial

<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

暫無
暫無

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

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