我正在Test-DbaNetworkLatency -SqlCredential sa
中运行powershell
,以测量sql服务器网络延迟。每次我运行命令时,都会提示输入密码。我计划在服务器上安排一个cronjob来定期运行此命令,因此我正在寻找一种避免每次输入密码的方法。谁能告诉我如何在Powershell中实现这一目标?
答案 0 :(得分:0)
您将需要为该功能创建凭据对象。
功能信息显示Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)
$password = ConvertTo-SecureString "Password" -AsPlainText -Force
$creds = New-Object System.Management.Automation.PSCredential ("sa", $password)
Test-DbaNetworkLatency -SqlCredential $creds