如何禁止 PowerShell 确认 DBATools New-DbaDbUser

huangapple go评论59阅读模式
英文:

How to suppress powershell confirmation DBATools New-DbaDbUser

问题

我正在尝试使用 dbatools 函数 New-DbaDbUserAdd-DbaDbRoleMember,以避免创建自己的版本,但我在跳过/抑制确认弹出窗口方面遇到了困难。

我已经尝试了几种 -Force-Confirm 等组合,但似乎什么都不起作用!

英文:

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!

答案1

得分: 0

我认为,引发确认窗口的不是DbaTools,因此我已经在调用函数时添加了

-Confirm:$false

例如:

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 

这样解决了问题,我不再收到确认提示了!太好了!

英文:

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!!!

huangapple
  • 本文由 发表于 2023年7月14日 06:36:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/76683663.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定