Skip to content

Commit

Permalink
Merge pull request #277 from kswietochowski/feature/SAM-12583-automat…
Browse files Browse the repository at this point in the history
…ion-scripts-for-appinsights

Added automation scripts for AppInsight applications
  • Loading branch information
danjagnow authored Apr 9, 2021
2 parents 97e5ffe + 1f113e0 commit 0a83acc
Show file tree
Hide file tree
Showing 7 changed files with 252 additions and 0 deletions.
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'."
}
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'."
}
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'."
}
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'."
}
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.
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'
)

0 comments on commit 0a83acc

Please sign in to comment.