Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $prtgurl = "http://127.0.0.1:80"
- $prtguser= ""
- $passhash= ""
- $oldcompany = "one"
- $newcompany = "two"
- ## /!\ don't change anything below /!\ ##
- $apicall = "/api/table.json?content=groups&output=json&columns=objid,name"
- $devices = "/api/table.json?content=devices&output=json&columns=objid,name"
- $apiGroups = [string]::Format("{0}/api/table.json?content={1}&output=json&columns=objid,name&username={2}&passhash={3}",$prtgurl,"groups",$prtguser,$passhash)
- $apiDevices = [string]::Format("{0}/api/table.json?content={1}&output=json&columns=objid,name&username={2}&passhash={3}",$prtgurl,"devices",$prtguser,$passhash)
- $Groups = (Invoke-WebRequest $apiGroups | ConvertFrom-Json)
- $Devices = (Invoke-WebRequest $apiDevices | ConvertFrom-Json)
- foreach($group in $Groups.groups){
- if($group.name -match $oldcompany){
- $name = $group.name -replace $oldcompany,$newcompany
- Invoke-WebRequest ([string]::Format("{0}/api/rename.htm?id={1}&value={2}&username={3}&passhash={4}", $prtgurl,$group.objid,$name,$prtguser,$passhash)) | Out-Null;
- }
- }
- foreach($Device in $Devices.devices){
- if($Device.name -match $oldcompany){
- $name = $Device.name -replace $oldcompany, $newcompany
- Invoke-WebRequest ([string]::Format("{0}/api/rename.htm?id={1}&value={2}&username={3}&passhash={4}", $prtgurl,$device.objid,$name,$prtguser,$passhash)) | Out-Null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement