# Using PowerShell to Query WebApis

**URL:** <https://community.squaredup.com/t/using-powershell-to-query-webapis/1712>\
**Category:** Dashboard Server\
**Tags:** powershell\
**Created:** [March 11, 2022, 12:58am UTC](https://community.squaredup.com/t/using-powershell-to-query-webapis/1712 "2022-03-11T00:58:26Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marcus](https://community.squaredup.com/letter_avatar_proxy/v4/letter/m/85e7bf/32.png) [@Marcus](https://community.squaredup.com/u/Marcus)\
**Post date:** [March 11, 2022, 12:58am UTC](https://community.squaredup.com/t/using-powershell-to-query-webapis/1712/1 "2022-03-11T00:58:26Z")

</div>

Hello All,

I’m trying to use the PowerShell module to query a WebApi and display data in a grid (can’t use the WebApi tile, because I need to request a token first).  
I have a script that’s running locally, but regardless of what I do in SquaredUp I get “PowerShell host process returned neither a result nor error”.

Can someone point me to some examples on how to use the PowerShell module to query a WebApi?

Thx in advance - M.

---

<div class="post-metadata">

**Author:** ![pchip](https://community.squaredup.com/letter_avatar_proxy/v4/letter/p/91b2a8/32.png) [@pchip](https://community.squaredup.com/u/pchip)\
**Post date:** [March 14, 2022, 4:41pm UTC](https://community.squaredup.com/t/using-powershell-to-query-webapis/1712/2 "2022-03-14T16:41:52Z")

</div>

Never tried it before for SQ, but likely you may want to have your script do a save a transcript then read on the transcript to see if any errors occurred when running under SQ.

---

<div class="post-metadata">

**Author:** ![Marcus](https://community.squaredup.com/letter_avatar_proxy/v4/letter/m/85e7bf/32.png) [@Marcus](https://community.squaredup.com/u/Marcus)\
**Post date:** [March 14, 2022, 10:19pm UTC](https://community.squaredup.com/t/using-powershell-to-query-webapis/1712/3 "2022-03-14T22:19:54Z")

</div>

Hello Pascal,  
pardon the question - how do I generate/save/view a “transcript”?

Thx in advance - M.

---

<div class="post-metadata">

**Author:** ![an\_evil\_penguin](https://community.squaredup.com/user_avatar/community.squaredup.com/an_evil_penguin/32/858_2.png) [@an\_evil\_penguin](https://community.squaredup.com/u/an_evil_penguin)\
**Post date:** [March 15, 2022, 12:50pm UTC](https://community.squaredup.com/t/using-powershell-to-query-webapis/1712/4 "2022-03-15T12:50:42Z")

</div>

There’s a great article on Transcript logging here: [Transcript Logging – Why you should do it « The Surly Admin](https://thesurlyadmin.com/2015/10/20/transcript-logging-why-you-should-do-it/)

---

<div class="post-metadata">

**Author:** ![jh1](https://community.squaredup.com/user_avatar/community.squaredup.com/jh1/32/847_2.png) [@jh1](https://community.squaredup.com/u/jh1)\
**Post date:** [March 15, 2022, 12:51pm UTC](https://community.squaredup.com/t/using-powershell-to-query-webapis/1712/5 "2022-03-15T12:51:44Z")

</div>

It depends on what you are trying to archive. I have a simple one running like this for a grid tile:  
`Invoke-RestMethod -Uri "https://<pathtosomeRSS-Feed>" -UseDefaultCredentials`

There are examples on github like vmware: [samples/dashboards/vmware-status at master · squaredup/samples · GitHub](https://github.com/squaredup/samples/tree/master/dashboards/vmware-status)  
[VMware Status Dashboard - SquaredUp](https://squaredup.com/dashboard-gallery/vmware-status-sample-dashboard/)  
And on the web site under resources:  
[Tips and tricks for building insightful visualizations with PowerShell - SquaredUp](https://squaredup.com/blog/build-insightful-visualizations-with-powershell/)  
Regards

---

<div class="post-metadata">

**Author:** ![Jelly](https://community.squaredup.com/user_avatar/community.squaredup.com/jelly/32/812_2.png) [@Jelly](https://community.squaredup.com/u/Jelly)\
**Post date:** [March 15, 2022, 12:54pm UTC](https://community.squaredup.com/t/using-powershell-to-query-webapis/1712/6 "2022-03-15T12:54:48Z")

</div>

Another option that we recommend for large data sets/scripts that might take a while to run is to have the script run _somewhere_ and output to a CSV, then use a simple script in SquaredUp to read the CSV instead. This way, SquaredUp loads the data much faster, as it doesn’t have the bulk of auth and querying the data source.

---

<div class="post-metadata">

**Author:** ![Marcus](https://community.squaredup.com/letter_avatar_proxy/v4/letter/m/85e7bf/32.png) [@Marcus](https://community.squaredup.com/u/Marcus)\
**Post date:** [March 16, 2022, 12:11am UTC](https://community.squaredup.com/t/using-powershell-to-query-webapis/1712/7 "2022-03-16T00:11:52Z")

</div>

Hey guys - thank you so much for all of your answers. Obviously, the community is alive and active - awesome !!!

Turns out my issue was due to the json parser (I’m calling it that) in SquaredUp stumbling over a special character. Took me a while to figure out how to use the log and log settings to trace this.

Once I figured out (with help from Afreen from support) that it was a character that was causing this, I took care of it with this:

$content = $response | ConvertTo-Json  
$content = $content -replace( [char]8220, “’”)  
$content = $content -replace( [char]8221, “’”)  
$finalresponse = $content | ConvertFrom-Json

Thx again to everyone!  
M.
