<# .SYNOPSIS Example function for '-WhatIf' parameter support. #> # Get-Help wont work if script starts with function... Write-Host "`n" (Get-Help $PSCommandPath).synopsis Function Test-WhatIf { [CmdletBinding(SupportsShouldProcess)] Param([String]$Objects) ForEach ($item in $Objects) { If ($PSCmdlet.ShouldProcess("$item", "Action")) { "Action: -> $item" # This will only run without '-WhatIf' } } } # Run the function Test-WhatIf "ITEM" -WhatIf