Hacker News new | ask | show | jobs
by andy81 1373 days ago
I'm no expert on web dev, mostly working in BI/DBA.

Running commands over WinRM or SSH can return objects of any type from remote machines. In the background I believe it's converting them to serialized CLIXML over the wire.

e.g. $RemotePSVersion = Invoke-Command -ComputerName 'SomeOtherComputer' -ScriptBlock {$PSVersionTable}

Rather than the variable $RemotePSVersion being a string it's an object with the type "System.Management.Automation.PSVersionHashTable", just like if you ran $PSVersionTable locally.

For anything that returns text (e.g. external tools like curl/robocopy) you'll usually convert to an object in your script before further processing. That way it can be passed into whatever next steps in a generic way.

e.g. curl https://catfact.ninja/fact | ConvertFrom-Json | Export-Csv '.\HighlyImportantInfo.csv'

curl https://catfact.ninja/fact | ConvertFrom-Json | Out-Gridview

That's less important when working interactively, but one major difference between Powershell/Bash is the relative focus on scripting vs interactive terminal use.