Installing feature in Azure startup task for Windows Server 2012
Asked Answered
F

1

5

I want to install the IP and Domain Restrictions feature in my Azure deployment, but I'm using os version 3 (Server 2012) which has depreciated ServerManageCmd, so the following code does not work:

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>

I believe I need to use powershell commands but I'm a little out of my depth here. Can anyone provide the 2012 equivalent of this code?

Fidellia answered 11/7, 2013 at 6:29 Comment(0)
F
10

For those playing at home, here's the answer!

@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
Fidellia answered 11/7, 2013 at 7:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.