by nodra on 1/20/23, 1:38 AM with 10 comments
I know bash is the standard but does anyone opt for powershell even on a Linux vm?
by richardjam73 on 1/20/23, 6:32 AM
I recently was looking at doing some backup software in Powershell for Windows 10 and 11. My chosen method was to use a VHDX file (Windows backup does this). Now in powershell there are commands to create a VHD or VHDX file but they are tied to the Hyper-V package in Windows being installed. In Windows 11 this package has been totally removed and can no longer be downloaded or installed.
So next I tried to find another way to use VHDX files in Windows 11 from Powershell. So I discovered that the diskpart command line utility can create/attach/partition etc VHDX files. Diskpart however is not integrated into powershell. In order to use it you need to create a text file with the commands to run. Execute diskpart with that text file. Then you have to search the text output for the results.
At this point I felt like I should have been using a Unix shell anyway.
by _ajoj on 1/20/23, 2:46 AM
Coming from bash the language is awkward. I would like to spend some time learning it more and running it on my main macOS machine.
[1] https://lazyadmin.nl/powershell/powershell-gui-howto-get-sta...
by majkinetor on 1/20/23, 7:06 AM
Even our GitLab runner uses pwsh.
To organizse build/scripts we use Invoke-Build, a cross-platform task runner: https://github.com/nightroman/Invoke-Build
by hiAndrewQuinn on 1/20/23, 7:12 AM
There is a bit of a painful paradigm shift, though, where you have to stop thinking in terms of text streams and more in terms of shuttling objects with properties around. It's not a great idea to try to work with PowerShell exactly the same way you might construct a pipeline around `awk` and `grep`, because text streams just aren't the real primitive in this environment. For that reason I think it usually makes sense to just a stick with whichever shell environment you grew up with, unless work or something forces your hand.
by pragmatick on 1/20/23, 9:56 AM
I just converted a bash script to a powershell script. Some things are a lot easier (like writing errors or info messages in different colors). But I had a lot of problems getting the exit codes from maven calls to determine the exit result. Checking for 0 in shell works fine all the time, in powershell checking $LASTERRORCODE works sometimes but not always. I'm using try catch now but it's a bit of a hassle (which is ironic, comic from a java developer).
by fomine3 on 1/20/23, 6:50 AM
by replwoacause on 1/20/23, 5:16 AM