Last active
June 13, 2021 06:42
-
-
Save lukemurraynz/3f0fa72c545aaa4caef54e66934a7f83 to your computer and use it in GitHub Desktop.
Add_LogAnalyticsWorkspace.ps1
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
<# | |
Author: Luke Murray (Luke.Geek.NZ) | |
Version: 0.1 | |
Version History: | |
Purpose: Add an MMA agent to a Log Analytics workspace using a proxy with no user authentication. | |
Notes: | |
Find more options about the MMA Agent Object: | |
#$healthServiceSettings = New-Object -ComObject 'AgentConfigManager.MgmtSvcCfg' | |
#$proxyMethod = $healthServiceSettings | Get-Member -Name 'SetProxyInfo' | |
If script is being published by Configuration as a package, create a Command Line installer: | |
"%Windir%\sysnative\WindowsPowerShell\v1.0\powershell.exe" -ExecutionPolicy Bypass -Command .\Add_LogAnalyticsWorkspace.ps1 | |
If the proxy requires authentication, then the following null entries need to be replaced with user,password: $mma.SetProxyInfo("$proxy","$null","$null"). If you aren't using a proxy then you can remove the entire mma.SetProxyInfo line. | |
Location: https://github.com/lukemurraynz/PowerOfTheShell/blob/master/OperationsMgr/Add_LogAnalyticsWorkspace.ps1 | |
#> | |
$workspaceId = "INSERTLOGANALYTICSWORKSPACEIDHERE" | |
$workspaceKey = "INSERTLOGANALYTICSWORKSPACEKEY" | |
$proxy = 'ProxyIP:PORT' | |
$mma = New-Object -ComObject 'AgentConfigManager.MgmtSvcCfg' | |
$mma.AddCloudWorkspace($workspaceId, $workspaceKey) | |
$mma.SetProxyInfo("$proxy","$null","$null") | |
$mma.ReloadConfiguration() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment