3 ms·
That's the one. It's for wrappers around existing CLI tools. Still feels experimental, but it's a nice idea to get objects from e.g. robocopy without dropping
by andy81 4y ago
That's the one.
It's for wrappers around existing CLI tools.
Still feels experimental, but it's a nice idea to get objects from e.g. robocopy without dropping into regex and parsing it yourself.
- an1sotropy 4y agoCool, thanks for the info. It is very intriguing, and I admit that until this HN thread I didn't know about powershell, or appreciate this totally different model for how to connect programs together. This is probably way off-topic now, and my question surely shows my ignorance, but do you know if there precedent for a program, once packaged to work within powershell (or maybe nushell), to use the associated input and output specification as the starting point for making a web interface to the same code (as bridged by a webserver)? Or have I just described .net ?
- andy81 4y agoI'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 https://catfact.ninja/fact | ConvertFrom-Json | Export-Csv '.\HighlyImportantInfo.csv' curl https://catfact.ninja/fact 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.