Skip to content

Instantly share code, notes, and snippets.

@MichaelRyom
Created April 14, 2018 16:57
Show Gist options
  • Save MichaelRyom/4eabbcf64d505e213cd92b086b174cb8 to your computer and use it in GitHub Desktop.
Save MichaelRyom/4eabbcf64d505e213cd92b086b174cb8 to your computer and use it in GitHub Desktop.
#Created by Michael Ryom
#Version 0.1
#2017
#Source: https://michaelryom.dk/export-settings-from-vrops/
#Variables
$username = "user"
$password = "password"
$vRopsFQDN = "vrops.MichaelRyom.dk"
$PageSize = "5000" #Maximum is 5000
$ExportPath = "C:\temp\"
#^End of variables
#vRops SSL certificate trust
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
}
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
#^End of SSL certificate trust
#Convert username and password till securestring
$secPw = ConvertTo-SecureString $password -AsPlainText -Force
$cred = New-Object PSCredential -ArgumentList $username,$secPw
#^End of Convert username and password till securestring
#Authentication, Groups and Users
#Export Authentication Sources
Foreach($Source in (Invoke-RestMethod -Method Get -Uri "https://$vRopsFQDN/suite-api/api/auth/sources" -Credential $cred).'auth-sources'.'auth-source'.links.link.href){
$OutFile = $ExportPath+"AuthSource-"+($Source.Split("/") | Select -Last 1)+".xml"
Invoke-Webrequest -Uri "https://$vRopsFQDN$Source" -Credential $cred -OutFile $OutFile
}
#Export Roles and their privilege
Foreach($Source in ((Invoke-RestMethod -Method Get -Uri "https://$vRopsFQDN/suite-api/api/auth/roles" -Credential $cred).'user-roles'.'user-role'.links.link | where {$_.rel -eq "SELF"}).href){
$OutFile = $ExportPath+"Roles-"+($Source.Split("/") | Select -Last 1)+".xml"
Invoke-Webrequest -Uri "https://$vRopsFQDN$Source" -Credential $cred -OutFile $OutFile
}
#Export Groups and their role and members
Foreach($Source in ((Invoke-RestMethod -Method Get -Uri "https://$vRopsFQDN/suite-api/api/auth/usergroups" -Credential $cred).'user-groups'.'user-group'.links.link | where {$_.rel -eq "SELF"}).href){
$OutFile = $ExportPath+"UserGroups-"+($Source.Split("/") | Select -Last 1)+".xml"
Invoke-Webrequest -Uri "https://$vRopsFQDN$Source" -Credential $cred -OutFile $OutFile
}
#Export Users and their groups and role
$OutFile = $ExportPath+"UserList"+".xml"
Invoke-Webrequest -Uri "https://$vRopsFQDN/suite-api/api/auth/users" -Credential $cred -OutFile $OutFile
#^End of Authentication, Groups and Users
#Export
#Export Supermetrics
$OutFile = $ExportPath+"SuperMetrics"+".xml"
Invoke-Webrequest -Uri "https://$vRopsFQDN/suite-api/api/supermetrics" -Credential $cred -OutFile $OutFile
#Export SymptomDefinitions
$OutFile = $ExportPath+"SymptomDefinitions"+".xml"
Invoke-Webrequest -Uri "https://$vRopsFQDN/suite-api/api/symptomdefinitions?pageSize=5000" -Credential $cred -OutFile $OutFile
#Export Solutions
$OutFile = $ExportPath+"solutions"+".xml"
Invoke-Webrequest -Uri "https://$vRopsFQDN/suite-api/api/solutions" -Credential $cred -OutFile $OutFile
#Export ReportDefinitions
$OutFile = $ExportPath+"ReportDefinitions"+".xml"
Invoke-Webrequest -Uri "https://$vRopsFQDN/suite-api/api/reportdefinitions" -Credential $cred -OutFile $OutFile
#Export Recommendations
$OutFile = $ExportPath+"Recommendations"+".xml"
Invoke-Webrequest -Uri "https://$vRopsFQDN/suite-api/api/recommendations" -Credential $cred -OutFile $OutFile
#Export Email Templates
$OutFile = $ExportPath+"EmailTemplates"+".xml"
Invoke-Webrequest -Uri "https://$vRopsFQDN/suite-api/api/notifications/email/templates" -Credential $cred -OutFile $OutFile
#Export Notifications Rules
$OutFile = $ExportPath+"NotificationsRules"+".xml"
Invoke-Webrequest -Uri "https://$vRopsFQDN/suite-api/api/notifications/rules" -Credential $cred -OutFile $OutFile
#Export Maintenanceschedules
$OutFile = $ExportPath+"Maintenanceschedules"+".xml"
Invoke-Webrequest -Uri "https://$vRopsFQDN/suite-api/api/maintenanceschedules" -Credential $cred -OutFile $OutFile
#Export Licenskeys
$OutFile = $ExportPath+"Licenskeys"+".xml"
Invoke-Webrequest -Uri "https://$vRopsFQDN/suite-api/api/deployment/licenses" -Credential $cred -OutFile $OutFile
#Export GlobalSettings
$OutFile = $ExportPath+"GlobalSettings"+".xml"
Invoke-Webrequest -Uri "https://$vRopsFQDN/suite-api/api/deployment/config/globalsettings" -Credential $cred -OutFile $OutFile
#Export SolutionsCredentials
$OutFile = $ExportPath+"SolutionsCredentials"+".xml"
Invoke-Webrequest -Uri "https://$vRopsFQDN/suite-api/api/credentials" -Credential $cred -OutFile $OutFile
#Export AlertPlugins
$OutFile = $ExportPath+"AlertPlugins"+".xml"
Invoke-Webrequest -Uri "https://$vRopsFQDN/suite-api/api/alertplugins" -Credential $cred -OutFile $OutFile
#Export AlertDefinitions
$OutFile = $ExportPath+"AlertDefinitions"+".xml"
Invoke-Webrequest -Uri "https://$vRopsFQDN/suite-api/api/alertdefinitions?pageSize=5000" -Credential $cred -OutFile $OutFile
#Export SolutionsAdapters
$OutFile = $ExportPath+"SolutionsAdapters"+".xml"
Invoke-Webrequest -Uri "https://$vRopsFQDN/suite-api/api/adapters" -Credential $cred -OutFile $OutFile
#Export ActionDefinitions
$OutFile = $ExportPath+"ActionDefinitions"+".xml"
Invoke-Webrequest -Uri "https://$vRopsFQDN/suite-api/api/actiondefinitions" -Credential $cred -OutFile $OutFile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment