Created
April 10, 2014 21:29
-
-
Save sandrinodimattia/10425245 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param | |
( | |
[string]$ServiceName, | |
[string]$VmName, | |
[string]$UserName, | |
[string]$Password | |
) | |
$ErrorActionPreference = "Stop" | |
Write-Host "" | |
Write-Host " Installing VM Agent on $VmName ($ServiceName)" | |
Write-Host "" | |
$uri = (Get-AzureWinRMUri -ServiceName $ServiceName -Name $VmName).ToString() | |
$securePassword = ConvertTo-SecureString -String $Password -AsPlainText -For | |
$credential = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $securePassword | |
Write-Host " - WinRM Uri: $uri" | |
Write-Host " - Connecting to VM using Remote PowerShell." | |
Write-Host "" | |
$session = New-PSSession -ConnectionUri $uri -Credential $credential -SessionOption (New-PSSessionOption -SkipCACheck) | |
Invoke-Command -Session $session -Scriptblock { | |
Write-Host " > Connected." | |
$vmAgentInstallationPath = "$env:temp\VmInstallerPath" | |
New-Item -ItemType Directory -Force -Path $vmAgentInstallationPath | Out-Null | |
cd $vmAgentInstallationPath | |
Write-Host " > Download path: $vmAgentInstallationPath" | |
(New-Object system.net.WebClient).DownloadFile("http://go.microsoft.com/fwlink/p/?LinkId=394789", "$vmAgentInstallationPath\VMAgent.msi"); | |
Write-Host " > Download success." | |
Write-Host " > Installing..." | |
Start-Process -FilePath "VMAgent.msi" -ArgumentList "/quiet /l* vmagent-installation.log" -Wait | |
Write-Host " > Installation complete. The installation logs can be found in the download path." | |
} | |
Remove-PSSession $session | |
Write-Host "" | |
Write-Host " - VM Agent installed. You can now start exploring the VM Extensions." | |
Write-Host "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment