Skip to content

Instantly share code, notes, and snippets.

@codingoutloud
Last active December 24, 2015 02:19
Show Gist options
  • Select an option

  • Save codingoutloud/6730043 to your computer and use it in GitHub Desktop.

Select an option

Save codingoutloud/6730043 to your computer and use it in GitHub Desktop.
Use this to "relax" the constraints on a Windows Azure VM - primarily for a Cloud Service VM. It also installs some handy tools. Goal is to make it easy to diagnose issues on a VM. If you use this, plan to reimage the VM afterwards.
# original: https://gist.github.com/codingoutloud/6730043
# (inspired by http://blogs.msdn.com/b/kwill/archive/2013/08/26/azuretools-the-diagnostic-utility-used-by-the-windows-azure-developer-support-team.aspx)
# MANUALLY FIRST DO THIS from ELEVATED PowerShell command prompt
<#
Set-ExecutionPolicy Unrestricted -Force ; New-Item -ItemType Directory -Path c:\tools ; cd c:\tools ; notepad c:\tools\relax.ps1
#>
<#
Set-ExecutionPolicy Unrestricted -Force; Get-PSDrive -PSProvider FileSystem
Nice to have: pin IE, CMD to task bar
Show DRIVES from command line:
get-psdrive -psprovider filesystem
#>
# http://stackoverflow.com/questions/9368305/disable-ie-security-on-windows-server-via-powershell
function Disable-InternetExplorerESC {
$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
Write-Host "IE Enhanced Security Configuration (ESC) has been disabled." -ForegroundColor Green
}
function Enable-InternetExplorerESC {
$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 1
Set-ItemProperty -Path $UserKey -Name "IsInstalled" -Value 1
Stop-Process -Name Explorer
Write-Host "IE Enhanced Security Configuration (ESC) has been enabled." -ForegroundColor Green
}
function Disable-UserAccessControl {
Set-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "ConsentPromptBehaviorAdmin" -Value 00000000
Write-Host "User Access Control (UAC) has been disabled." -ForegroundColor Green
}
# http://www.howtogeek.com/tips/how-to-extract-zip-files-using-powershell/
function Expand-ZIPFile($file, $destination)
{
$shell = new-object -com shell.application
$zip = $shell.NameSpace($file)
foreach($item in $zip.items())
{
$shell.Namespace($destination).copyhere($item)
}
}
function Unzip($src, $dst)
{
# requires .NET 4.5
[System.Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.FileSystem") | Out-Null
[System.IO.Compression.ZipFile]::ExtractToDirectory($src, $dst)
}
Set-ExecutionPolicy Unrestricted -Force
Disable-InternetExplorerESC
Disable-UserAccessControl
$exists = Test-Path -PathType Container 'c:\tools'
if ($exists -eq $false) {
Echo "create"
New-Item 'c:\tools' -Type Directory
}
cd c:\tools
Import-Module BitsTransfer
Start-BitsTransfer http://dsazure.blob.core.windows.net/azuretools/AzureTools.exe c:\tools\AzureTools.exe
c:\tools\AzureTools.exe
$src = 'http://grepwin.googlecode.com/files/grepWin-1.6.1-64.msi'
$dst = 'c:\tools\grepWin.msi'
(New-Object System.Net.WebClient).DownloadFile($src,$dst)
$dst
$src = 'https://github.com/downloads/mikehadlow/AsmSpy/AsmSpy.zip'
$dst = 'c:\tools\AsmSpy.zip'
(New-Object System.Net.WebClient).DownloadFile($src,$dst)
## Expand-ZIPFile –File $dst –Destination 'c:\tools\asmspy.exe'
Unzip $dst 'c:\tools\asmspy'
copy 'c:\tools\asmspy\asmspy.exe' 'c:\tools\asmspy.exe'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment