Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Passing a ShouldProcess response down the call stack

$
0
0

Hi, does anybody know how to pass a ShouldProcess response to nested cmdlet and function calls?  Do cmdlets handle this already?  Can a function be written in such a way to accept a "yes to all" from the function calling it? 

If I know the function is nested, I could use the parent scope. 

(Get-Variable pscmdlet -Scope 1).Value.ShouldProcess(...)

However, this assumes the function will always be nested which I don't want to do.  I suppose I could try to test if the function is nested first.  Use the parent scope if it exists, otherwise use the local scope? 

Is there a standard/correct way to handle this?

Thanks. 


Randy in Marin


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>