Skip to content

Not passing the right credentials? #3

@vcuMDD

Description

@vcuMDD

I'm having trouble trying to use GMSACredential to connect to a SQL Server with sqlcmd. Here's my current set up:

  1. I'm opening powershell with my normal AD account, which has permissions on the SQL server.
  2. I'm successfully getting the credential using Get-GMSACredential.
  3. I'm using Invoke-GMSACommand to execute a SELECT SUSER_NAME() query on the SQL server.

Expected result: the query will show the gMSA as the account connected to the SQL Server.
Actual result: the query shows my account as account connected to the SQL Server.

Here's my code:

$Cred = Get-GMSACredential -GMSAName 'TheGMSA' -Domain 'TheDomain'
Invoke-GMSACommand -Credential $Cred -ScriptBlock { sqlcmd -E -S TheSQLServer -Q "SELECT SUSER_NAME()" -Y 20 }

Am I misunderstanding the expected usage and the credentials to be passed? Is there a better way to use GMSACredential to run a query on a SQL Server (that we don't control)?

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions