2013-07-11 20 views
5

Tôi muốn cài đặt tính năng Giới hạn IP và Miền trong triển khai Azure, nhưng tôi đang sử dụng phiên bản os 3 (Máy chủ 2012) đã khấu hao ServerManageCmd, vì vậy mã sau không không hoạt động:Cài đặt tính năng trong tác vụ khởi động Azure cho Windows Server 2012

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 phần

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

Tôi tin rằng tôi cần phải sử dụng lệnh powershell nhưng tôi là một chút ra khỏi chiều sâu của tôi ở đây. Bất cứ ai có thể cung cấp mã tương đương 2012 của mã này?

Trả lời

10

Đối với những người đang chơi ở nhà, đây là câu trả lời!

@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 
Các vấn đề liên quan