Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing feature in Azure startup task for Windows Server 2012

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?

like image 399
BenC3 Avatar asked Jul 11 '13 06:07

BenC3


People also ask

How do I enable Windows features on Server 2012?

NET 3.5 SP1 on Windows Server 2012 operating system: Open Control Panel, Program and Features (or Control Panel, Uninstall a program depending on your view setting). Click Turn Windows features on or off.

What is install during automatic maintenance?

Automatic maintenance will install updates when the computer is not in use, and will avoid installing updates when the computer is running on battery power. If automatic maintenance can't install updates within days, Windows Update will install updates right away. Users will then be notified about a pending restart.


1 Answers

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
like image 128
BenC3 Avatar answered Oct 20 '22 00:10

BenC3