Skip to content
Discussion options

You must be logged in to vote

I was both under and overcomplicating it.

So once I figured out my method above, I found it was bad because you don't supply the names of devices / power feeds / etc, you need to supply their object IDs. I don't want to have to remember what a named object's ID is all the time, so I came up with this.

$getPowerFeeds = (Invoke-RestMethod -Uri $api_base_url/dcim/power-feeds/ -Headers $headers).results
$getPowerPorts = (Invoke-RestMethod -Uri $api_base_url/dcim/power-ports/ -Headers $headers).results

$PDU_Name       = "A01 PDU A"
$PowerFeed_Name = "230-A01-A"

$PowerPort_ID = ($getPowerPorts | Where-Object {$_.device.name -eq $PDU_Name} | Select-Object ID).ID
$PDU_ID       = ($getPowerPorts | 

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by jsenecal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant