Shauryaink Prominent Jan 8, 2021 39 1 535 Mar 23, 2021 #1 How to know that the command on powershell is completed successfully Plz tell guys
Solution Ralston18 Mar 23, 2021 In agreement with all of the above. Overall more information is needed about the specific requirements you need with respect to any given cmdlet or script. Basically, as I understand your post you simply want to know that there were no errors and what you wanted to have happen actually happened. Likely a bit tricky.... And better fitted to scripts I think versus just running an one liner cmdlet. ==== Powershell has error handling and exception capabilities.... try catch finally References: https://www.webservertalk.com/powershell-try-catch-tutorial-guide https://www.tutorialspoint.com/explain-try-catch-finally-block-in-powershell
In agreement with all of the above. Overall more information is needed about the specific requirements you need with respect to any given cmdlet or script. Basically, as I understand your post you simply want to know that there were no errors and what you wanted to have happen actually happened. Likely a bit tricky.... And better fitted to scripts I think versus just running an one liner cmdlet. ==== Powershell has error handling and exception capabilities.... try catch finally References: https://www.webservertalk.com/powershell-try-catch-tutorial-guide https://www.tutorialspoint.com/explain-try-catch-finally-block-in-powershell
Colif Win 11 Master Moderator Jun 12, 2015 65,180 6,432 168,090 Mar 23, 2021 #2 what command? Upvote 0 Downvote
USAFRet Titan Moderator Mar 16, 2013 171,329 17,830 184,590 Mar 23, 2021 #3 Shauryaink said: How to know that the command on powershell is completed successfully Plz tell guys Click to expand... Did it throw an error? Did it do what it was supposed to do? Upvote 0 Downvote
Shauryaink said: How to know that the command on powershell is completed successfully Plz tell guys Click to expand... Did it throw an error? Did it do what it was supposed to do?
H hotaru.hino Glorious Sep 1, 2020 9,571 3,487 46,090 Mar 23, 2021 #4 Whether or not the command reports a successful completion depends on the command. Basic commands usually operate on the principle of "no news is good news." Upvote 0 Downvote
Whether or not the command reports a successful completion depends on the command. Basic commands usually operate on the principle of "no news is good news."
Ralston18 Titan Moderator Oct 11, 2014 34,816 3,309 146,290 Mar 23, 2021 Solution #5 In agreement with all of the above. Overall more information is needed about the specific requirements you need with respect to any given cmdlet or script. Basically, as I understand your post you simply want to know that there were no errors and what you wanted to have happen actually happened. Likely a bit tricky.... And better fitted to scripts I think versus just running an one liner cmdlet. ==== Powershell has error handling and exception capabilities.... try catch finally References: https://www.webservertalk.com/powershell-try-catch-tutorial-guide https://www.tutorialspoint.com/explain-try-catch-finally-block-in-powershell Upvote 0 Downvote Solution
In agreement with all of the above. Overall more information is needed about the specific requirements you need with respect to any given cmdlet or script. Basically, as I understand your post you simply want to know that there were no errors and what you wanted to have happen actually happened. Likely a bit tricky.... And better fitted to scripts I think versus just running an one liner cmdlet. ==== Powershell has error handling and exception capabilities.... try catch finally References: https://www.webservertalk.com/powershell-try-catch-tutorial-guide https://www.tutorialspoint.com/explain-try-catch-finally-block-in-powershell
H hotaru.hino Glorious Sep 1, 2020 9,571 3,487 46,090 Mar 23, 2021 #6 Looking into this a little more, I ran into this https://www.saotn.org/powershell-return-value-exit-code-or-errorlevel-equivalent/ Basically after the command you want to run, you need to add this: Bash: if($?) { # Do something if successful } As an example if you really want to run this in the command line itself and not through a script: Bash: cp file_1.txt file_1_copy.txt;if($?) { echo "Success!"} Upvote 0 Downvote
Looking into this a little more, I ran into this https://www.saotn.org/powershell-return-value-exit-code-or-errorlevel-equivalent/ Basically after the command you want to run, you need to add this: Bash: if($?) { # Do something if successful } As an example if you really want to run this in the command line itself and not through a script: Bash: cp file_1.txt file_1_copy.txt;if($?) { echo "Success!"}