PowerShell - Scripting Best Practices
You wrote this function:
But when you run
function Delete-Data {
param([string]$File)
if ($PSCmdlet.ShouldProcess($File)) {
Remove-Item $File
}
}But when you run
Delete-Data -File 'data.txt' -Confirm, it does not ask for confirmation. Why?