Can't pass variable into Copy-DbaAgentJob from array #7274
Unanswered
simon-smart
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, I'm pretty new to PowerShell so apologies if this is a really simple problem! but I am trying to run the Copy-DbaAgentJob cmdlet within a ForEach loop of agent jobs that have changed recently, but I am struggling to get the variable for the -Job parameter to pass into the cmdlet. Here is my basic script:
The idea being that the ##Jobs temp table in SQL is populated with a list of applicable agent jobs. My test case has 1 job - "dbatools_testJob" in the list. Returning the $Jobs variable shows the variable has been successfully populated,
However the cmdlet does not run. What's odd is if i hard-code the job name into the cmdlet, it will work, so the ForEach loops is operating fine, but it won't pass the $i variable and I can't see why.
Hard-coded -Job parameter
Returns
If anyone has any advice it would be greatly appreciated. Thanks!
Beta Was this translation helpful? Give feedback.
All reactions