# Read powershell output

**URL:** <https://forums.powershell.org/t/read-powershell-output/15562>\
**Category:** PowerShell Help\
**Created:** [January 31, 2021, 8:35am UTC](https://forums.powershell.org/t/read-powershell-output/15562 "2021-01-31T08:35:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![avinash](https://avatars.discourse-cdn.com/v4/letter/a/ed655f/32.png) [@avinash](https://forums.powershell.org/u/avinash)\
**Post date:** [January 31, 2021, 8:35am UTC](https://forums.powershell.org/t/read-powershell-output/15562/1 "2021-01-31T08:35:26Z")

</div>

How to read the powershell output from a variable like below which is not properly formatted.

Sample:

\> $description

**Alert:&nbsp;** KNA Application error rate is high
\<p style="box-sizing:borde r-box;"\>\</p\>\<p style="box-sizing:border-box;"\> **Alert ID:&nbsp;** 68191403bc3b3bff7e9e9dc32e755dfcaf585979\</p\>\<p style="box- sizing:border-box;"\> **Source:&nbsp;** LogAnalytics\</p\>\<p style="box-sizing:border-box;"\> **Qu ery:&nbsp;** let window = 15m; let threshhold = 85; union workspace('df8524f4-72d6-48bf-bb6e-60320621d1ec').CF\_HttpStartStop\_CL,workspace('1d5cd2c8-8461-430 0-b5c0-b50eaa69b0ab').CF\_HttpStartStop\_CL,workspace('e65f915e-d3c4-471b-89eb-3613cd1f3c54').CF\_HttpStartStop\_CL,workspace('998825ae-9217-45f0-9bcd-60240936a734').CF\_HttpS tartStop\_CL,workspace('ff3815e3-d9ab-43c4-ac7f-f7cf82a67acc').CF\_HttpStartStop\_CL,workspace('70d40933-9fb1-4afe-9c05-3d142430c105').CF\_HttpStartStop\_CL,workspace('df8524f 4-72d6-48bf-bb6e-60320621d1ec').CF\_HttpStartStop\_CL,workspace('1d5cd2c8-8461-4300-b5c0-b50eaa69b0ab').CF\_HttpStartStop\_CL | where TimeGenerated &gt;= ago(window) | where ApplicationName\_s == 'alliance-platform-notifications-prod' or ApplicationName\_s == 'alliance-platform-notifications-New' | extend statuscode\_s=tostring(toint(StatusCode\_ d)) | summarize rate=(countif(statuscode\_s == '200' or statuscode\_s == '404' or statuscode\_s == '401')\*100)/count() by ApplicationName\_s, Environment\_s | where rate &lt;= threshhold | project Resource=strcat('Error rate is high in application', ' - ',ApplicationName\_s,' - ',' | In Region',' - ',Environment\_s)\</p\>\<p style="box-sizing:borde r-box;"\> **AlertSeverity:&nbsp;** SEV C\</p\>\<p style="box-sizing:border-box;"\> **MonitorConditi on:&nbsp;** AlertFramework\</p\>\<p style="box-sizing:border-box;"\> **QueryResponse:** \</p\>\<table style="box-sizing:border-box; border-collapse:collapse;border-spacing:0px;margin:0px;"\>Resou rceError rate is high in application - alliance-platform-notifications-prod - | In Region - krError rate is high in application - alliance-platform-notifications-prod - | In Region - eu\<p style="box-sizing:border-box;"\> **Resource:&nbsp;** Error rate is high in application - all iance-platform-notifications-prod - | In Region - eu\</p\>\<br\>

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [January 31, 2021, 10:36am UTC](https://forums.powershell.org/t/read-powershell-output/15562/2 "2021-01-31T10:36:48Z")

</div>

When you post code, error messages, sample data or console output format it as code, please.

Here you can read how it works: [Guide to Posting Code](https://powershell.org/forums/topic/guide-to-posting-code-2/)

Please edit your already existing post - do not create a new one.

And you may share the code you used to produce this output. It may help answering your question. Most of the time it is better to create the output you’re after the way ou want it in the first place.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![avinash](https://avatars.discourse-cdn.com/v4/letter/a/ed655f/32.png) [@avinash](https://forums.powershell.org/u/avinash)\
**Post date:** [January 31, 2021, 6:45pm UTC](https://forums.powershell.org/t/read-powershell-output/15562/3 "2021-01-31T18:45:43Z")

</div>

[quote quote=289441]When you post code, error messages, sample data or console output format it as code, please.

Here you can read how it works: [Guide to Posting Code](https://powershell.org/forums/topic/guide-to-posting-code-2/)

Please edit your already existing post – do not create a new one.

And you may share the code you used to produce this output. It may help answering your question. Most of the time it is better to create the output you’re after the way ou want it in the first place.

Thanks in advance.

[/quote]  
The above is not a code .That is the output stored in a variable.I just wanted to know how to select some text /line from that variable.

---

<div class="post-metadata">

**Author:** ![rob-simmers](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/rob-simmers/32/1010_2.png) [@rob-simmers](https://forums.powershell.org/u/rob-simmers)\
**Post date:** [February 1, 2021, 3:24am UTC](https://forums.powershell.org/t/read-powershell-output/15562/4 "2021-02-01T03:24:59Z")

</div>

This depends on how you are populating the variable. The variable appears to be HTML, so there are ways to populate and parse that with HTML DOM. Post the code that is populating the variable.

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [February 1, 2021, 10:02am UTC](https://forums.powershell.org/t/read-powershell-output/15562/5 "2021-02-01T10:02:07Z")

</div>

> [@](#):
>
> The above is not a code .That is the output stored in a variable.I just wanted to know how to select some text /line from that variable.

I did not say it is code. When you carefully read my answer again you will see that I asked you to format **console output** as code as well. 😉

Anyway. I think it would be helpful when you share the code you used to get this output.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:27pm UTC](https://forums.powershell.org/t/read-powershell-output/15562/6 "2024-05-16T20:27:55Z")

</div>


