Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Stream Output For SupportsShouldProcess

$
0
0

Hi guys, 

I'm using CmdletBinding() within some of my custom Powershell Functions which I've into modules. I've just used Dave Wyatt's Get-CallerPreference to resolve the passing of common parameters to ensure -Verbose and -Debug are supported as I have logging functions which write to file. 

I'm able to log everything to file. Verbose, Debug, standard output, warnings and errors are all written to file successfully with some stream redirection for commands like Invoke-SQLCmd. 

I've got SupportsShouldProcess set to $True for some functions where the ConfirmPreference is more than Medium. What I'm finding is when I try and write the output to file, a boolean is returned, presumably because $PSCmdlet.ShouldProcess is enclosed within an If statement like below:

if ($pscmdlet.ShouldProcess($ENV:COMPUTERNAME, "Remove this file"))
{

}

What I'm looking for is to be able to write the confirm and whatif statements to file for auditing purposes. Does the ShouldProcess statement use Write-Host and the output is lost or am I missing something?

Is there a way I could have found this information and answered this for myself?

Thanks


Viewing all articles
Browse latest Browse all 15028

Latest Images

Trending Articles



Latest Images

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