Making PowerShell safe by default is trivial. Ulf here suggested that “socially responsible” PowerShell needs to use -WhatIf by default for all operations, and actually perform the actions only if explicitly asked to do so.
To make PowerShell operate in this mode, all you need to do is set
$WhatIfPreference variable to $true, and use
-WhatIf:$false when you do want something to be executed. (colon is mandatory by the way – because this is a switch parameter).
Here’s my session (copy/pasted from PowerShell Console pane of PowerGUI Script Editor):
C:\> $WhatIfPreference = $true
C:\> Get-Process notepad
Handles NPM(K) PM(K) WS(K) Id ProcessName
------- ------ ----- ----- -- -----------
63 3 2372 6668 66 notepad
C:\> Get-Process notepad | Stop-Process
What if: Performing operation "Stop-Process" on Target "notepad (4708)".
C:\> Get-Process notepad | Stop-Process -WhatIf:$false