dataplat / dbachecks

✔ SQL Server Environmental Validation
https://dbachecks.readthedocs.io/en/latest/
MIT License
460 stars 141 forks source link

-Credential switch for invoke-dbccheck is not passing the specified credentials #1012

Open ap-tnt opened 1 year ago

ap-tnt commented 1 year ago

Bug Report

General Troubleshooting steps

Does (Find-Module dbachecks).Version match (Get-Module dbachecks).Version.ToString() Yep

Version Information

Steps to Reproduce

$cred = Get-Credential -UserName 'domain\user1' invoke-dbccheck -sqlinstance "sql01" -check lastgoodcheckdb -Credential $cred

Description of Bug

I would like the above code to connect to sql01 using the domain\user1 account. However, it runs invoke-dbccheck as the user who is running Powershell. I can verify that the credentials running Powershell are being used to connect to sql01, as there are login failures on sql01 relating to said user, and the credentials running Powershell do not have any permissions to connect to sql01.