0

I have a Powershell script which, when ran, gives some warnings. when i ran this script using Powershell then it completes successfully but when i ran it from Powerise it stops at the warning. How can I ignore warnings in Powerise so that the script can execute completely? Powershell version 5. Below is the warning

warning CS0169: The field 'RedeemControllerTest.PostMethod._environment' is never used

wonderwall
  • 146
  • 1
  • 11
  • [Maybe related](http://stackoverflow.com/q/30709884/1630171). – Ansgar Wiechers May 15 '17 at 23:06
  • Can you provide enough of the script for someone to replicate the problem? – DeanOC May 15 '17 at 23:41
  • @DeanOC: i dont think I can because its a long script and contains name of my company and other companies in the functions and in comments. Dont you think its related to Power ISE, Like power ISE stops the script on warning but powershell does not. – wonderwall May 16 '17 at 01:14
  • ISE doesn't stop on warning by default. Likely there's some other difference occurring when you're running via ISE. Does the warning also show when running in PS? i.e. if not that suggests something else is different to cause the warning. If it does, what other code may be running after the error; could it be something there which is causing things to lock up? Have you tried running your code with the -DEBUG switch to see which line the "hang" occurs on? – JohnLBevan May 16 '17 at 11:43

2 Answers2

1

The error you are refering to is as far as I can see related to compiling C#. So maybe your script is trying to start a compiler? The provided error would then be located in the C# source code the compiler is working with.

The error just tells you that a variable is never used in the code and should be removed.

  • Thanks for the answer but I am not worried about the error. I am worried about why PowerISE is not stopping the script on this error. – wonderwall May 28 '17 at 23:59
0

Can u set the "-ErrorAction "SilentlyContinue"" parameter? Need more data to pinpoint your issue bud. Perhaps update your post with a snippet of the script. As for sensitive information - You gotta scramble that, or share it anyways, if you want any help mate.

  • I tried, It did not work. I dont think it has anything to do with the code because the same code stops when i run it in powershell but keeps on running when ran in powershell ise. SO its ISE settings. I will have to change a lot of things in the script to make it visible and its also very big. Thanks anyway. – wonderwall May 25 '17 at 01:49