Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New-DbaAgentJobStep -DatabaseUser is not setting the username for the job. #9378

Closed
Xyaran opened this issue Jun 4, 2024 · 2 comments · Fixed by #9380
Closed

New-DbaAgentJobStep -DatabaseUser is not setting the username for the job. #9378

Xyaran opened this issue Jun 4, 2024 · 2 comments · Fixed by #9380

Comments

@Xyaran
Copy link

Xyaran commented Jun 4, 2024

Verified issue does not already exist?

I have searched and found no existing issue

What error did you receive?

I'm not getting any error, but the username is not set inside the job step.

Steps to Reproduce

    $newJobParams = @{
        SqlInstance = $dataWarehouseConfiguration.FullSqlServerInstance
        SqlCredential = GetDbCredential($dataWarehouseConfiguration)
        Job = 'Run Job'
        Database = $dataWarehouseConfiguration.SqlServerDatabaseName
        OnSuccessAction = 'GotoNextStep'
        Confirm = $false
    }

    New-DbaAgentJobStep @newJobParams -StepId 1  `
                                      -StepName 'Update Datawarehouse Objects'  `
                                      -OnFailAction 'QuitWithFailure' -RetryAttempts 5 -RetryInterval 1  `
                                      -DatabaseUser "$login"  `
                                      -Subsystem 'TransactSql'  `
                                      -Command 'EXEC [dbo].[usp_UpdateDWObjects]'  `
        | Out-Null

Please confirm that you are running the most recent version of dbatools

2.1.14

Other details or mentions

Set-DbaAgentJobStep -DatabaseUser is setting the username properly.

I looked into the code, New-DbaAgentJobStep.ps1 line 344 is not checking the right variable ($DatabaseName instead of $Database)

What PowerShell host was used when producing this error

Windows PowerShell (powershell.exe)

PowerShell Host Version

Name Value


PSVersion 5.1.26100.461
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.26100.461
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

SQL Server Edition and Build number

Microsoft SQL Server 2019 (RTM-CU26) (KB5035123) - 15.0.4365.2 (X64) Mar 29 2024 23:02:47 Copyright (C) 2019 Microsoft Corporation Developer Edition (64-bit) on Windows Server 2019 Standard 10.0 (Build 17763: ) (Hypervisor)

.NET Framework Version

.NET Framework 4.8.9232.0

@Xyaran Xyaran added bugs life triage required New issue that has not been reviewed by maintainers labels Jun 4, 2024
@andreasjordan
Copy link
Contributor

Thanks for reporting this, a fix is on its way...

@andreasjordan andreasjordan removed the triage required New issue that has not been reviewed by maintainers label Jun 5, 2024
@Xyaran
Copy link
Author

Xyaran commented Jun 6, 2024

Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants