Showing category results for PowerTip

Nov 18, 2016
Post comments count0
Post likes count0

PowerTip: Return a status code to Linux from PowerShell

Doctor Scripto
Doctor Scripto

Summary: Pass a result code back to a calling Linux environment from Open Source PowerShell. How can I pass a numeric value back to a calling Bash Shell to indicate an error? Just simply supply the EXIT command and a numeric value at the point where the error is flagged. For example, the following code is a PowerShell script that returns a value...

Windows PowerShellPowerTipguest blogger
Nov 11, 2016
Post comments count0
Post likes count0

PowerTip: Get the status code of a PowerShell script in Bash

Doctor Scripto
Doctor Scripto

Summary: Identify the results of a script running in Open Source PowerShell in a Bash environment. Is there any way to see the results of a PowerShell script? For example, if somebody sent an “Exit 42”, could I see it in Linux? All you need to do is examine the $? variable in Linux, just like any other Linux application. Here is an example:

Windows PowerShellPowerTipguest blogger
Nov 4, 2016
Post comments count0
Post likes count0

PowerTip: Capture error code of a PowerShell session in Linux or macOS

Doctor Scripto
Doctor Scripto

Summary: Capture the status code of a PowerShell session in Linux or macOS. Could you show me how to run a PowerShell script in Linux or macOS and capture the status of whether that script succeeded or failed? No problem, my friend. Just run the PowerShell session, and start the script as in the following example. You can view the status in the ...

Windows PowerShellPowerTipguest blogger
Oct 28, 2016
Post comments count0
Post likes count0

PowerTip: Know the difference between the .split() method and ‘-split’

Doctor Scripto
Doctor Scripto

Summary: Cloud and Datacenter Management MVP, Thomas Rayner, shows how to split a string by using a string instead of just a character. I am trying to split the string “this is my amazing string” on the pattern “my” by using “this is my amazing string”.split(“my”) but it’s giving me a bunch of garbled stuff back. How do I accomplish my goal?  You...

Windows PowerShellPowerTipguest blogger
Oct 21, 2016
Post comments count0
Post likes count0

PowerTip: How to use regular expressions to split a string without losing the character you split on

Doctor Scripto
Doctor Scripto

Summary: Cloud and Datacenter Management MVP, Thomas Rayner, shows how to split a string without losing the character you split on. I’m splitting this file name some file.txt into its name and extension by going “some file.txt” –split “.”. It’s giving me some file and txt, but I want to keep the dot and get .txt instead. How can I do this? You c...

Windows PowerShellPowerTipguest blogger