July 11, 2018 at 8:38 am
I am trying to use the Dbatools powershell module, but when I try to pass an AD credential, it is not seeming to work for me. I tried using both Invoke-Sqlcmd2 and Invoke-DbaSqlquery. I am passing a Pscredential object to them as an argument. The $Cred Variable is where I am storing my PSCredential Invoke-SqlCmd2 -SqlInstance "DEV01" -Query "SELECT SYSTEM_USER" -Credential $cred
results in a login failed for the correct user ($cred.UserName)Invoke-DbaSqlQuery -SqlInstance "DEV01" -Query "SELECT SYSTEM_USER" -SqlCredential $Cred
results in a failed login for the user I am using in powershell (not the user from $cred)
I have checked to make sure that the $cred variable is a valid credential, and I can start a new PowerShell session as the user from $Cred without any issue, and any process I start using start-process runs correctly as the user from $cred. Am I invoking the command(s) incorrectly?
September 13, 2018 at 6:41 am
In case anyone else comes here from Google, it took some time before I finally figured out what was going on
It's this issue, still open, in dbatools: https://github.com/sqlcollaborative/dbatools/issues/3780
Until it gets resolved in a later version, I was able to get my scripts functioning again by installing version 0.9.342:
Uninstall-Module dbatools
Install-Module dbatools -RequiredVersion 0.9.342
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy