0

I am running Test-DbaNetworkLatency -SqlCredential sa in powershell to measure sql server network latency. It prompts input password each time I run the command. I am planning to schedule a cronjob on my server to run this command regularly so I am looking for a way to avoid typing password each time. Can anyone tell me how I can achieve that in powershell?

Joey Yi Zhao
  • 37,514
  • 71
  • 268
  • 523

1 Answers1

0

You will need to create a credential object for the function. The function info shows 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
Drew
  • 3,814
  • 2
  • 9
  • 28