I've created a function to remove old installed modules and have added SupportsShouldProcess to cmdletbinding. From my understanding the -WhatIf switch should be passed down to any native cmdlet that already supports -WhatIf with no need to add $PSCmdlet.ShouldProcess(). Uninstall-Module supports -WhatIf but when i run the below function with -WhatIf it still uninstalls the old modules. What gives?
I believe you still need to tell the shell that your function supports both -confirm and -whatif. The way you actually implement that support is to write conditional code around whatever dangerous stuff your cmdlet is planning to do