Puppet PowerShell api connection

427 views
Skip to first unread message

Elwin Hidding

unread,
Oct 19, 2015, 2:47:14 PM10/19/15
to Puppet Users
I do not see my last post and cannot find it, so 2nd try.

I am trying to make a connection from PowerShell to the Puppet API.
The CURL example on: http://docs.puppetlabs.com/puppetdb/2.3/api/query/v3/facts.html shows me this:

curl -X GET http://puppetdb:8080/v3/facts --data-urlencode 'query=["=", "name", "operatingsystem"]'



I can get it to work in PowerShell without the query part with this:

Invoke-WebRequest -Uri "http://puppetdb:8080/v3/facts" -Method Get



Has anyone any knowledge on how i can add the query part?
Looping through the whole output is very time consuming and i want to make use of the query feature to save time.

David Schmitt

unread,
Oct 20, 2015, 12:11:11 PM10/20/15
to puppet...@googlegroups.com


On 19/10/2015 19:38, Elwin Hidding wrote:
I do not see my last post and cannot find it, so 2nd try.

I am trying to make a connection from PowerShell to the Puppet API.
The CURL example on: http://docs.puppetlabs.com/puppetdb/2.3/api/query/v3/facts.html shows me this:

curl -X GET http://puppetdb:8080/v3/facts --data-urlencode 'query=["=", "name", "operatingsystem"]'



I can get it to work in PowerShell without the query part with this:

Invoke-WebRequest -Uri "http://puppetdb:8080/v3/facts" -Method Get



Has anyone any knowledge on how i can add the query part?

http://stackoverflow.com/a/17330952 shows how to pass arguments to a POST request, I'd assume that the GET works the same.

 
Invoke-WebRequest -Uri "http://puppetdb:8080/v3/facts" -Method Get -Body @{query='["=", "name", "operatingsystem"]'}


Cheers, David
Reply all
Reply to author
Forward
0 new messages