How to Skip Confirmation in a PowerShell Script

I have recently used PowerShell script to add user to AD groups. It works pretty well except it asks for confirmation everything I run Add-ADGroupMember. It’s cumbersome if you have a lot of groups in your script. Later I found out, the solution is quite easy. You just add -Confirm:$false to the end of the command. The complete command is like this

Add-ADGroupMember ad-group ad-user -Confirm:$false