Linked Questions

90 votes
12 answers
241k views

How to Use -confirm in PowerShell

I'm trying to take user input and before proceeding I would like get a message on screen and than a confirmation, whether user wants to proceed or not. I'm using the following code but its not working:...
user3770612's user avatar
  • 1,719
84 votes
2 answers
198k views

What exactly is "exit" in PowerShell?

You can exit PowerShell by typing exit. So far so good. But what exactly is this? PS Home:\> gcm exit Get-Command : The term 'exit' is not recognized as the name of a cmdlet, function, script file,...
Joey's user avatar
  • 350k
4 votes
4 answers
1k views

how to prevent external script from terminating your script with break statement

I am calling an external .ps1 file which contains a break statement in certain error conditions. I would like to somehow catch this scenario, allow any externally printed messages to show as normal, ...
DannyMeister's user avatar
  • 1,291
0 votes
1 answer
847 views

Why Is my "If Else" statement getting skipped?

I am working on a script to allow my sys admins to make changes to an ACL without having to drill down to the folder level. So far, everything is executing as intended except for my first "If..Else" ...
T4RH33L's user avatar
  • 159
1 vote
1 answer
758 views

How to terminate the script execution in case commandlet encounters error

I need to terminate the whole script execution if command let encounters the error. The whole script after that must never execute. In my case, If I use ThrowTerminatingError, it just stops the ...
Usman's user avatar
  • 2,852
0 votes
2 answers
2k views

Error code 255 when trying to kick off a TFS2013 team build via a PostBuildEvent

I'm trying to kick off a team build when another team build finishes, so I've added this to the .csproj of the project being built: <PropertyGroup Condition=" $(IsDesktopBuild) == 'false' "> &...
Ben_G's user avatar
  • 800
2 votes
2 answers
812 views

Powershell "Exit" not behaving like it should

I had a strange Problem occurring in one of my PowerShell scripts today: Enviroment Information: the PowerShell script im talking about is being called by a VBScript. if($VM -eq "Yes") { Add-...
Ceuse's user avatar
  • 23
2 votes
1 answer
482 views

Why does this simple Powershell script not exit when needed?

I have a simple Powershell script derived from here which is supposed to exit when a certain condition becomes true (file deleted, modified, etc.) The script: $watcher = New-Object System.IO....
learnerX's user avatar
  • 1,042
1 vote
2 answers
759 views

How can I make my script stop when clicked on the cancel Button?

I am working on a script that gives you prompts for copying whole folderstructures including the ACLs (permissions) My Question now is how can I make it so that when I click on the cancel button in ...
Martin Schmidt's user avatar
0 votes
1 answer
817 views

What is the effect of the -ErrorAction Stop for an Invoke-Expression statement?

I am using Invoke-Expression on each line of a file. If one of the lines causes an error, I would like to stop executing. I have tried using -ErrorAction Stop but it has no effect. What is supposed ...
Tevya's user avatar
  • 856
0 votes
1 answer
699 views

Powershell terminate execution

I am using powershell to process csv files in a directory when no file found with current date stamp I want the process to raise an error notifying file not found and exit. # Powershell raise error ...
pbj's user avatar
  • 663
0 votes
0 answers
412 views

Powershell exit script to examine variables

I usually add temporary code to show running variables and when the script is ready I have to delete this code. Is there any way of terminate a script (.ps1) (quit / exit / break / ... ) called from ...
ZEE's user avatar
  • 3,051