Last active
April 17, 2017 00:32
-
-
Save thereverand/90924c649146af69a3ad3f150b80931f to your computer and use it in GitHub Desktop.
Configures a machine monitored with the Microsoft Monitoring Agent as a Hybrid Worker for use with Azure Automation; without needing to know the version the agent you are running.
This file contains 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
[cmdletbinding()] | |
param( | |
[parameter(Mandatory=$true)] | |
[string]$Url, | |
[parameter(Mandatory=$true)] | |
[string]$Key, | |
[parameter(Mandatory=$true)] | |
[string]$GroupName | |
) | |
# The path to the latest version of the MMAgent | |
# Get all the folders for installed versions | |
# Sort them by Name, cast to a Version, from newest to oldest | |
# And Select the latest (first) one. | |
$latestPath = | |
Get-ChildItem -Path "C:\Program Files\Microsoft Monitoring Agent\Agent\AzureAutomation\" ` | |
| Sort-Object { [Version]$_.Name } -Descending ` | |
| Select-Object -First 1; | |
# Import the Hybrid Registration module | |
Import-Module "$latestPath\HybridRegistration\HybridRegistration.psd1"; | |
# Enable this machine as a Hybrid Worker for Azure Automation with the supplied parameters. | |
Add-HybridRunbookWorker –Url $Url -Key $Key -GroupName $GroupName; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment