Sometimes line continuations are quite permissive
[datetime]::ParseExact( 'septiembre', 'MMMM', (get-culture 'es') ).ToString('MMMM', (get-culture 'es'))| # This is a ps5 + ps7 script | |
| # ps5 writes errors when PBI refreshes, ps7 either never does, or its much, much more rare | |
| $dest = 'C:\Users\cppmo_000\AppData\Local\Temp\cults.csv' | |
| $iter = 0 | |
| while($true) { | |
| $iter++ | |
| $Last = [datetime]::Now | |
| $content = w32tm /stripchart /computer:time.google.com /samples:1 /dataonly | |
| Add-Content -Path $dest -Value ( |
| using namespace System.Management.Automation | |
| using namespace System.Management.Automation.Language | |
| $Tokens = $null | |
| $AstErrors = $Null | |
| $doc = [Parser]::ParseFile( | |
| <# fileName: #> $file, | |
| <# tokens : #> [ref] $tokens, | |
| <# errors : #> [ref] $AstErrors ) |
| [xml]$doc = gc (Join-Path $PSScriptRoot './sample.xml') | |
| [xml]$Doc = @' | |
| <?xml version="1.0" encoding="utf-8"?> | |
| <configuration> | |
| <setting name = "logLevel" value = "verbose" /> | |
| <setting name = "root" value = "c:/foo" desc = "users root dir" /> | |
| </configuration> | |
| '@ |
| function Format-ControlChar { | |
| <# | |
| .synopsis | |
| converts ANSI control chars into human-visible symbols. | |
| .description | |
| Because they are not ansi escapes ( control chars ), they have no special meaning | |
| so they are save to pipe to your terminal or transport. | |
| This is written in for Pwsh7 because it simplifes code | |
| #> |
| let | |
| /* testing delays in query diagnostics */ | |
| seconds = 5, | |
| resp1 = [ | |
| Bytes = Web.Contents( "https://httpbin.org", [ RelativePath = "/links/3/1" ] ), | |
| Who = Diagnostics.ActivityId() | |
| ], | |
| resp2 = | |
| Function.InvokeAfter( |
| #Requires -Module 'PSParseHtml' | |
| <# | |
| .Synopsis | |
| Combining a simple `CSS` / `XPath` query with regex works fairly well to find `icon` resources | |
| #> | |
| [Uri] $Url = 'https://na.alienwarearena.com' | |
| $xpath_doc ??= ConvertFrom-Html -Url $Url -Engine AgilityPack | |
| $css_doc ??= ConvertFrom-Html -Url $Url -Engine AngleSharp |
More info / Docs :
AutomaticDecompression]OP was using the same Invoke-WebRequest|RestMethod code on Ps5 and Ps7 with different results.