Let's say I have this:
[System.Version]::new(1, 2, 3, 4)
How can I convert it into "3.4"? I'm interested in piping it if possible to avoid having to create an intermediary variable.
this is ugly but it works inline fairly well. it uses the .Split() option to put the results into a specific number of items with all the remaining ones added to the last one.
([version]'1.2.3.4').ToString().Split('.', 3)[-1]
output = 3.4
Another ugly but inline solution, uses ForEach-Object to get at the piped reference.
[System.Version]::new(1, 2, 3, 4) | ForEach-Object { "$($_.Build).$($_.Revision)" }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With