Skip to content

Instantly share code, notes, and snippets.

@lrakai
Last active January 14, 2022 22:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lrakai/ce41350bfcad154fab058288d302de51 to your computer and use it in GitHub Desktop.
Save lrakai/ce41350bfcad154fab058288d302de51 to your computer and use it in GitHub Desktop.
Azure Windows Server Nested VM Host Init
<#
Azure Nested VM Host Configuration
.File Name
- InstallHyperV.ps1
.What calls this script?
- This is a PowerShell Script run as a Custom Script extention called by azure-deploy.json
.What does this script do?
- Downloads NuGet package provider
- Installs the DscResource and xHyper-V PS modules in support of the upcoming DSC Extenion run in HyperVHostConfig.ps1
- Installs Hyper-V with all Features and Management Tools and then Restarts the Machine
#>
Set-ExecutionPolicy Unrestricted -Force
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]'Tls11,Tls12'
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
Find-Module -Includes DscResource -Name xHyper-v | Install-Module -Force
# Disable Server Manager pop up
Get-ScheduledTask -TaskName ServerManager | Disable-ScheduledTask -Verbose
# Disable Windows Defender real-time monitoring
Set-MpPreference -DisableRealtimeMonitoring $true
# Disable IE Enhanced Security
# $AdminKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}"
# $UserKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}"
# Set-ItemProperty -Path $AdminKey -Name "IsInstalled" -Value 0
# Set-ItemProperty -Path $UserKey -Name "IsInstalled" -Value 0
# Stop-Process -Name Explorer -ErrorAction Continue
#Install Hyper-V and Reboot
Install-WindowsFeature -Name Hyper-V `
-IncludeAllSubFeature `
-IncludeManagementTools `
-Verbose `
-Restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment