Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.