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

Set-DbaAgentJobStep -Job and -StepName parameters should be able to accept pipeline input and $variable input #4350

Closed
wsuhoey opened this issue Oct 26, 2018 · 4 comments · Fixed by #5030
Assignees

Comments

@wsuhoey
Copy link
Collaborator

wsuhoey commented Oct 26, 2018


Set-DbaAgentJobStep -Job and -StepName parameters should be able to accept pipeline input

Summary of new feature

The -Job parameter and -StepName parameter of Set-DbaAgentJobStep should be able to accept pipeline input, such as piped from Get-DbaAgentJobStep and/or Get-DbaAgentJob.
They also do not accept $variable input, throwing "Cannot convert value to type System.String" errors.

For example, this does not work and I expected it to:

Get-DbaAgentJob -SqlInstance MYSERVER | Set-DbaAgentJobStep -Database MYDATABASE

This also did not work:

Get-DbaAgentJobStep -SqlInstance MYSERVER | Set-DbaAgentJobStep -Database MYDATABASE

This also did not work:

$agentjobs = Get-DbaAgentJob -SqlInstance MYSERVER | Select-Object -ExpandProperty Name
$agentjobsteps = Get-DbaAgentJobStep -SqlInstance MYSERVER | Select-Object -ExpandProperty Name
Set-DbaAgentJobStep -SqlInstance MYSERVER -Job $agentjobs -StepName $agentjobsteps -Database MYDATABASE

which throws red error:

Set-DbaAgentJobStep : Cannot process argument transformation on parameter 'StepName'. Cannot convert value to type System.String.
At line:1 char:70
+ ... qlInstance MYSERVER -Job $agentjobs -StepName $agentjobsteps -Databa ...
+                                                    ~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Set-DbaAgentJobStep], ParameterBindingArgumentTransformationException
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,Set-DbaAgentJobStep

Proposed technical details (if applicable)

I am not smart enough to know how to technically solve this :( :) :(
But the only way I could figure out to get this to KIND OF work (while throwing a bunch of warnings for every cartesian product possible combination) was to:

$agentjobs = Get-DbaAgentJob -SqlInstance MYSERVER | Select-Object -ExpandProperty Name
$agentjobsteps = Get-DbaAgentJobStep -SqlInstance MYSERVER | Select-Object -ExpandProperty Name
foreach ( $job in $agentjobs )
{
    foreach ( $jobstep in $agentjobsteps )
    {
       Set-DbaAgentJobStep -SqlInstance MYSERVER -Job $job -StepName $jobstep -Database MYDATABASE 
    }
}

Latest version of dbatools as of writing

  • Please provide the latest released version of dbatools module.
    0.9.490
@stale
Copy link

stale bot commented Dec 30, 2018

This issue has been automatically marked as stale because it has not had recent activity. If you would like this issue to remain open:

  • Verify that you can still reproduce the issue in the latest version of dbatools
  • Comment that the issue is still reproducible and include:
    • What version of dbatools you reproduced the issue on
    • What OS and version you reproduced the issue on
    • What steps you followed to reproduce the issue

@stale stale bot added the wontfix label Dec 30, 2018
@stale
Copy link

stale bot commented Jan 30, 2019

This issue has been automatically closed because it has not had activity in the last three months. If this issue is still valid, please add a comment

@stale stale bot closed this as completed Jan 30, 2019
@sanderstad sanderstad reopened this Jan 30, 2019
@stale stale bot removed the wontfix label Jan 30, 2019
@sanderstad
Copy link
Contributor

I want to check if this is still the case

@sanderstad
Copy link
Contributor

Sorry for the delay but the function should not accept pipes from Get-DbaAgentJobStep.

The command allows to get the job steps from get-DbaAgentJobStep and get those changes and push those to other servers and jobs and eventually job steps.

image

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.

3 participants