Skip to content

Instantly share code, notes, and snippets.

@robdmoore
Last active August 29, 2015 14:22
Show Gist options
  • Save robdmoore/d2b0fb0ae8f1ff104194 to your computer and use it in GitHub Desktop.
Save robdmoore/d2b0fb0ae8f1ff104194 to your computer and use it in GitHub Desktop.
Install App Insights into Virtual Machine using PowerShell
function Install-AppInsights($instrumentationKey) {
mkdir c:\tempappinsights -Force
pushd c:\tempappinsights
try {
(New-Object Net.WebClient).DownloadFile('http://appinsightsstatusmonitor.blob.core.windows.net/statusmonitor/ApplicationInsights.ps1.zip',"c:\tempappinsights\ApplicationInsights.ps1.zip")
Expand-ZipFile C:\tempappinsights\ApplicationInsights.ps1.zip c:\tempappinsights
. C:\tempappinsights\ApplicationInsights.ps1
ApplicationInsightsConfig $instrumentationKey
Start-DscConfiguration -Path C:\tempappinsights\ApplicationInsightsConfig -ComputerName localhost
} finally {
popd
}
}
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)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment