PowerShell
Goal
Write a PowerShell block that reads nested JSON and publishes one compact line. Time: 10 minutes. Needs: pwsh.
Things to know
- Files run with
-NoProfile -NonInteractive -ExecutionPolicy Bypass, so your profile isn’t loaded. -Rawreads the whole file.-LiteralPathstops PowerShell treating[and*in the path as wildcards.- Always use
-Compress. Without it,ConvertTo-Jsonprints several lines and breaks the last-line rule. Add-Depthfor nested objects. $ErrorActionPreference = 'Stop'turns non-terminating errors into failures.- Captured Command Prompt commands become PowerShell blocks that call
cmd.exethrough%ComSpec%.
Check your run
Execute step prints {"message":"Hello from curl"}.
Exercise
Publish upper (the text in upper case) and length (number) in the same object.