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

If you’re thinking about purchasing a new GPU, we’d greatly appreciate it if you used our Amazon Associate links. The price you pay will be exactly the same, but Amazon provides us with a small commission for each purchase. It’s a simple way to support our site and helps us keep creating useful content for you. Recommended GPUs: RTX 5090, RTX 5080, and RTX 5070. #ad

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

 

Be the first to comment

Leave a Reply