Skip to content

Instantly share code, notes, and snippets.

@stephanlinke
Last active June 30, 2023 11:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephanlinke/e2a5374568d6e3ff942fb1b696e7d5e5 to your computer and use it in GitHub Desktop.
Save stephanlinke/e2a5374568d6e3ff942fb1b696e7d5e5 to your computer and use it in GitHub Desktop.
Update Master Dependencies throughout PRTG
# USE AT YOUR OWN RISK.
# This will reset the dependencies of all ping sensors to be the master object for their parent.
# Your PRTG Server's FQDN, i.e. prtg.acme.com
$PRTGServer = "prtg.acme.com"
# proper message output
Function This-ShowMessage([string]$type,$message){
Write-Host ("[{0}] " -f (Get-Date)) -NoNewline;
switch ($type){
"success" { Write-Host " success " -BackgroundColor Green -ForegroundColor White -NoNewline; }
"information" { Write-Host " information " -BackgroundColor DarkCyan -ForegroundColor White -NoNewline; }
"warning" { Write-Host " warning " -BackgroundColor DarkYellow -ForegroundColor White -NoNewline; }
"error" { Write-Host " error " -BackgroundColor DarkRed -ForegroundColor White -NoNewline; }
default { Write-Host " notes " -BackgroundColor DarkGray -ForegroundColor White -NoNewline; }
}
Write-Host (" {0}{1}" -f $message,$Global:blank)
}
This-ShowMessage -type information "[PRTG Ping Fixer] This will configure ping sensors to be the master object for their parent"
Connect-PrtgServer -Server $PRTGServer -Credential (Get-Credential -Message "Please enter your PRTG Credentials (Username and Password)") -Force -IgnoreSSL
This-ShowMessage -type information "Creating configuration backup..."
Backup-PrtgConfig
# Get all sensors first
$Sensors = (Get-Sensor -Type Ping)
This-ShowMessage -type information "Found $($Sensors.Count) Ping Sensor(s). This is your last chance to stop via CTRL+C..."
$Sensors | ft
Start-Sleep -Seconds 10
# Dependency set to "Master Object For Parent"
$dependency = @{
scheduledependency = 0
dependencytype_ = 2
DependentObjectId = 0
DependencyDelay = 0
}
Foreach($Sensor in $Sensors){
$Sensor | Set-ObjectProperty -RawParameters $dependency -Force
This-ShowMessage -type success "Updated [$($Sensor.Device)] $($Sensor.Name)"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment