Note that there are some explanatory texts on larger screens.

plurals
  1. POPowerShell VB.NET cmdlet. Change -DEBUG switch
    text
    copied!<p>The trying to prevent the (apparently default) Inquire mode in WriteDebug and this does not work (See earlier post). As I do not yet know how to detect if -DEBUG is set on the command line I am trying this:</p> <pre><code>(&lt;Cmdlet(VerbsDiagnostic.Test, "MyCmdlet", SupportsShouldProcess:=False)&gt; _ Protected Overrides Sub BeginProcessing() setting = SessionState.PSVariable dbPref = setting.Get("DebugPreference").Value vbPref = setting.Get("VerbosePreference").Value WriteObject("VBpref: " &amp; vbPref.ToString) WriteObject("DBpref: " &amp; dbPref.ToString) setting.Set("VerbosePreference", ActionPreference.Continue) setting.Set("DebugPreference", ActionPreference.Continue) dbPref = setting.Get("DebugPreference").Value vbPref = setting.Get("VerbosePreference").Value WriteObject("VBpref: " &amp; vbPref.ToString) WriteObject("DBpref: " &amp; dbPref.ToString) WriteDebug("TEST") </code></pre> <p>The ouput is as follows:</p> <pre><code>PS&gt; Test-MyCmdlet -d VBpref: SilentlyContinue DBpref: SilentlyContinue VBpref: Continue DBpref: Continue DEBUG: TEST Confirm Continue with this operation? [Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"): </code></pre> <p>And this is the output without the -D switch (no Inquire):</p> <pre><code>PS&gt; Test-MyCmdlet VBpref: SilentlyContinue DBpref: SilentlyContinue VBpref: Continue DBpref: Continue DEBUG: TEST </code></pre> <p>So why, if the reset above has worked, am I still in Inquire mode? And how can I change it?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload