-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #277 from kswietochowski/feature/SAM-12583-automat…
…ion-scripts-for-appinsights Added automation scripts for AppInsight applications
- Loading branch information
Showing
7 changed files
with
252 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
Samples/PowerShell/SAM.AppInsightAutomation/CreateAppInsightForActiveDirectory.ps1
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
Import-Module SwisPowerShell | ||
|
||
$appSettings = @{}; | ||
$appSettings.Add('Port', '389'); | ||
$appSettings.Add('GCPort', '3268'); | ||
$appSettings.Add('EncryptionMethod', '0'); # 0 - None, 1 - SSL | ||
$appSettings.Add('AuthenticationMethod', '2'); # 0 - Anonymus, 1 - Simple, 2 - Ntlm, 3 - Kerberos, 4 - Negotiate | ||
$appSettings.Add('IgnoreCertificateErrors', 'true'); | ||
#To disable domain components please use DisableDomainComponents verb on Orion.APM.ActiveDirectory.Application entity, this verb will always set EnableDomainComponent = true | ||
|
||
$hostname = "10.150.12.21" | ||
$username = "admin" | ||
$plainTextPassword = "admin" | ||
$password = $plainTextPassword | ConvertTo-SecureString -AsPlainText -Force | ||
|
||
$cred = New-Object -typename System.Management.Automation.PSCredential -argumentlist $username, $password | ||
$swis = Connect-Swis -host $hostname -cred $cred | ||
|
||
$nodeId = 20 | ||
$credentialSetId = -3 #-3 means take it from node | ||
|
||
$template = "AppInsight for Active Directory" | ||
$applicationTemplateId = Get-SwisData $swis "SELECT ApplicationTemplateID FROM Orion.APM.ApplicationTemplate WHERE Name=@template" @{ template = $template } | ||
|
||
if (!$applicationTemplateId) { | ||
Write-Host "Can't find template with name '$template'." | ||
exit 1 | ||
} | ||
|
||
Write-Host "Creating application on node '$nodeId' using template '$applicationTemplateId' and credential '$credentialSetId'." | ||
|
||
$applicationId = (Invoke-SwisVerb $swis "Orion.APM.Application" "CreateApplication" @( | ||
$nodeId, | ||
$applicationTemplateId, | ||
$credentialSetId, | ||
"true", | ||
$appSettings | ||
)).InnerText | ||
|
||
# Check if the application was created | ||
if ($applicationId -eq -1) { | ||
Write-Host "Application wasn't created. Likely the template is already assigned to node and the skipping of duplications are set to 'true'." | ||
exit 1 | ||
} | ||
else { | ||
Write-Host "Application created with ID '$applicationId'." | ||
} |
43 changes: 43 additions & 0 deletions
43
Samples/PowerShell/SAM.AppInsightAutomation/CreateAppInsightForExchange.ps1
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
Import-Module SwisPowerShell | ||
|
||
$appSettings = @{}; | ||
$appSettings.Add('PsUrlWindows', 'https://${IP}:5986/wsman/'); | ||
$appSettings.Add('PsUrlExchange', 'https://${IP}/powershell/'); | ||
|
||
$hostname = "10.150.12.21" | ||
$username = "admin" | ||
$plainTextPassword = "admin" | ||
$password = $plainTextPassword | ConvertTo-SecureString -AsPlainText -Force | ||
|
||
$cred = New-Object -typename System.Management.Automation.PSCredential -argumentlist $username, $password | ||
$swis = Connect-Swis -host $hostname -cred $cred | ||
|
||
$nodeId = 5 | ||
$credentialSetId = -3 #-3 means take it from node | ||
|
||
$template = "AppInsight for Exchange" | ||
$applicationTemplateId = Get-SwisData $swis "SELECT ApplicationTemplateID FROM Orion.APM.ApplicationTemplate WHERE Name=@template" @{ template = $template } | ||
|
||
if (!$applicationTemplateId) { | ||
Write-Host "Can't find template with name '$template'." | ||
exit 1 | ||
} | ||
|
||
Write-Host "Creating application on node '$nodeId' using template '$applicationTemplateId' and credential '$credentialSetId'." | ||
|
||
$applicationId = (Invoke-SwisVerb $swis "Orion.APM.Application" "CreateApplication" @( | ||
$nodeId, | ||
$applicationTemplateId, | ||
$credentialSetId, | ||
"true", | ||
$appSettings | ||
)).InnerText | ||
|
||
# Check if the application was created | ||
if ($applicationId -eq -1) { | ||
Write-Host "Application wasn't created. Likely the template is already assigned to node and the skipping of duplications are set to 'true'." | ||
exit 1 | ||
} | ||
else { | ||
Write-Host "Application created with ID '$applicationId'." | ||
} |
43 changes: 43 additions & 0 deletions
43
Samples/PowerShell/SAM.AppInsightAutomation/CreateAppInsightForIIS.ps1
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
Import-Module SwisPowerShell | ||
|
||
$appSettings = @{}; | ||
$appSettings.Add('NodeIpAddress', '10.150.12.21'); | ||
$appSettings.Add('PsUrlWindowsValue', 'https://${IP}:5986/wsman/'); | ||
|
||
$hostname = "10.150.12.21" | ||
$username = "admin" | ||
$plainTextPassword = "admin" | ||
$password = $plainTextPassword | ConvertTo-SecureString -AsPlainText -Force | ||
|
||
$cred = New-Object -typename System.Management.Automation.PSCredential -argumentlist $username, $password | ||
$swis = Connect-Swis -host $hostname -cred $cred | ||
|
||
$nodeId = 2 | ||
$credentialSetId = -3 #-3 means take it from node | ||
|
||
$template = "AppInsight for IIS" | ||
$applicationTemplateId = Get-SwisData $swis "SELECT ApplicationTemplateID FROM Orion.APM.ApplicationTemplate WHERE Name=@template" @{ template = $template } | ||
|
||
if (!$applicationTemplateId) { | ||
Write-Host "Can't find template with name '$template'." | ||
exit 1 | ||
} | ||
|
||
Write-Host "Creating application on node '$nodeId' using template '$applicationTemplateId' and credential '$credentialSetId'." | ||
|
||
$applicationId = (Invoke-SwisVerb $swis "Orion.APM.Application" "CreateApplication" @( | ||
$nodeId, | ||
$applicationTemplateId, | ||
$credentialSetId, | ||
"true", | ||
$appSettings | ||
)).InnerText | ||
|
||
# Check if the application was created | ||
if ($applicationId -eq -1) { | ||
Write-Host "Application wasn't created. Likely the template is already assigned to node and the skipping of duplications are set to 'true'." | ||
exit 1 | ||
} | ||
else { | ||
Write-Host "Application created with ID '$applicationId'." | ||
} |
44 changes: 44 additions & 0 deletions
44
Samples/PowerShell/SAM.AppInsightAutomation/CreateAppInsightForSQL.ps1
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
Import-Module SwisPowerShell | ||
|
||
$appSettings = @{}; | ||
#$appSettings.Add('InstanceName', ''); #instance name is not required, if not specified than default instance name will be used | ||
$appSettings.Add('PortType', 'static'); #default or static, when static than PortNumber needs to be set | ||
$appSettings.Add('PortNumber', '1433'); | ||
|
||
$hostname = "10.150.12.21" | ||
$username = "admin" | ||
$plainTextPassword = "admin" | ||
$password = $plainTextPassword | ConvertTo-SecureString -AsPlainText -Force | ||
|
||
$cred = New-Object -typename System.Management.Automation.PSCredential -argumentlist $username, $password | ||
$swis = Connect-Swis -host $hostname -cred $cred | ||
|
||
$nodeId = 2 | ||
$credentialSetId = -3 #-3 means take it from node | ||
|
||
$template = "AppInsight for SQL" | ||
$applicationTemplateId = Get-SwisData $swis "SELECT ApplicationTemplateID FROM Orion.APM.ApplicationTemplate WHERE Name=@template" @{ template = $template } | ||
|
||
if (!$applicationTemplateId) { | ||
Write-Host "Can't find template with name '$template'." | ||
exit 1 | ||
} | ||
|
||
Write-Host "Creating application on node '$nodeId' using template '$applicationTemplateId' and credential '$credentialSetId'." | ||
|
||
$applicationId = (Invoke-SwisVerb $swis "Orion.APM.Application" "CreateApplication" @( | ||
$nodeId, | ||
$applicationTemplateId, | ||
$credentialSetId, | ||
"true", | ||
$appSettings | ||
)).InnerText | ||
|
||
# Check if the application was created | ||
if ($applicationId -eq -1) { | ||
Write-Host "Application wasn't created. Likely the template is already assigned to node and the skipping of duplications are set to 'true'." | ||
exit 1 | ||
} | ||
else { | ||
Write-Host "Application created with ID '$applicationId'." | ||
} |
42 changes: 42 additions & 0 deletions
42
Samples/PowerShell/SAM.AppInsightAutomation/CreateWindowsScheduledTasks.ps1
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
Import-Module SwisPowerShell | ||
|
||
$appSettings = @{}; | ||
$appSettings.Add('NodeIpAddress', '10.150.17.112'); | ||
|
||
$hostname = "10.150.16.71" | ||
$username = "admin" | ||
$plainTextPassword = "123" | ||
$password = $plainTextPassword | ConvertTo-SecureString -AsPlainText -Force | ||
|
||
$cred = New-Object -typename System.Management.Automation.PSCredential -argumentlist $username, $password | ||
$swis = Connect-Swis -host $hostname -cred $cred | ||
|
||
$nodeId = 2 | ||
$credentialSetId = -3 #-3 means take it from node | ||
|
||
$template = "Windows Scheduled Tasks" | ||
$applicationTemplateId = Get-SwisData $swis "SELECT ApplicationTemplateID FROM Orion.APM.ApplicationTemplate WHERE Name=@template" @{ template = $template } | ||
|
||
if (!$applicationTemplateId) { | ||
Write-Host "Can't find template with name '$template'." | ||
exit 1 | ||
} | ||
|
||
Write-Host "Creating application on node '$nodeId' using template '$applicationTemplateId' and credential '$credentialSetId'." | ||
|
||
$applicationId = (Invoke-SwisVerb $swis "Orion.APM.Application" "CreateApplication" @( | ||
$nodeId, | ||
$applicationTemplateId, | ||
$credentialSetId, | ||
"true", | ||
$appSettings | ||
)).InnerText | ||
|
||
# Check if the application was created | ||
if ($applicationId -eq -1) { | ||
Write-Host "Application wasn't created. Likely the template is already assigned to node and the skipping of duplications are set to 'true'." | ||
exit 1 | ||
} | ||
else { | ||
Write-Host "Application created with ID '$applicationId'." | ||
} |
Binary file not shown.
33 changes: 33 additions & 0 deletions
33
Samples/PowerShell/SAM.AppInsightAutomation/SetupAppInsightApplication.ps1
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
Import-Module SwisPowerShell | ||
|
||
#orion machine settings | ||
$hostname = "hostname" | ||
$username = "Admin" | ||
$plainTextPassword = "a" | ||
$password = $plainTextPassword | ConvertTo-SecureString -AsPlainText -Force | ||
|
||
$cred = New-Object -typename System.Management.Automation.PSCredential -argumentlist $username, $password | ||
$swis = Connect-Swis -host $hostname -cred $cred | ||
|
||
#target node settings | ||
$nodeName = 'nodeName' | ||
$nodeIp = 'nodeIp' | ||
$nodeId = 1 | ||
$credentialSetId = 1 | ||
|
||
$template = "AppInsight for IIS" | ||
$applicationTemplateId = Get-SwisData $swis "SELECT ApplicationTemplateID FROM Orion.APM.ApplicationTemplate WHERE Name=@template" @{ template = $template } | ||
|
||
if (!$applicationTemplateId) { | ||
Write-Host "Can't find template with name '$template'." | ||
exit 1 | ||
} | ||
|
||
Invoke-SwisVerb $swis "Orion.APM.Application" "SetupApplication" @( | ||
$nodeName, | ||
$nodeIp, | ||
$credentialSetId, | ||
$applicationTemplateId, | ||
$nodeId, | ||
'true' | ||
) |