Create a test to see if the command line had “-verbose” on it. Then run something.
if ($PSBoundParameters.verbose) {
Get-Item -Path "$OutputFile"
}
Here’s another way (found at StackOverflow.)
function DoStuff {
[CmdletBinding()]
param()
process {
if ($PSBoundParameters['Verbose']) {
# do verbose stuff
}
New-Item Test -Type Directory -Verbose:($PSBoundParameters['Verbose'] -eq $true)
}
}
