I'm trying to use the dbatools functions New-DbaDbUser
and Add-DbaDbRoleMember
to avoid creating my own version, but struggle to get the confirmation pop up window skipped/suppressed.
I have tried several combinations of -Force
and -Confirm
and so on, but nothing seems to be working!
I think, it wasn't DbaTools that was raising the confirmation windows hence I have added
-Confirm:$false
when calling the functions:
New-DbaDbUser -SqlInstance $srvNameTarget -Database $dbNameTarget -Login $existingUsers.login[$i] -Username $existingUsers.name[$i] -Confirm:$false
Add-DbaDbRoleMember -SqlInstance $srvNameTarget -Database $dbNameTarget -Role $RoleMembers[$j].Role -User $exisitngUsers.name[$i] -Confirm:$false
And this resolved the issue and I no longer get prompt for confirmation! Yay!!!