Closed rwyoung01 closed 5 years ago
Are you using the Powershell run type or the Operating system run type?
From: rwyoung01 notifications@github.com Sent: Thursday, May 30, 2019 5:28 PM To: rubrikinc/rubrik-scripts-for-powershell Cc: Subscribed Subject: [rubrikinc/rubrik-scripts-for-powershell] Export-RubrikDatabasejob pass json file in SQL Server Agent Job (#91)
When I use the following script in a SQL Agent job as a cmdshell script type
powershell.exe D:\Powershell\Rubrik\Export-RubrikDatabasejob.ps1 -Jobfile Export-RubrikDatabaseJobFile.json Nothing happens and I get the following message in the job history
The step did not generate any output. Process Exit Code 0. The step succeeded.
If I trying the script as a Powershell type D:\Powershell\Rubrik\Export-RubrikDatabasejob.ps1 -Jobfile Export-RubrikDatabaseJobFile.json
I get the following message
A job step received an error at line 177 in a PowerShell script. The corresponding line is ' } while ($RubrikRequestInfo.status -notin $ExitList) '. Correct the script and reschedule the job. The error information returned by PowerShell is: 'You must provide a value expression on the right-hand side of the '-' operator. '. Process Exit Code -1. The step failed.
The only way it will run is not passing the json file as a parm. Do you know what I am doing wrong
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Frubrikinc%2Frubrik-scripts-for-powershell%2Fissues%2F91%3Femail_source%3Dnotifications%26email_token%3DAFKMBSBJYXFMME3V3WYT67DPYBBJFA5CNFSM4HRL2OW2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4GW2J6QA&data=02%7C01%7C%7Cb242996db0c04604043408d6e545cf95%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636948485324617384&sdata=2N3GHn3rOKqfuPObP%2FW1Ed0yrjw4ay0lKDk0F3JcK4U%3D&reserved=0, or mute the threadhttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAFKMBSG45G3PG6LW6J5OJSDPYBBJFANCNFSM4HRL2OWQ&data=02%7C01%7C%7Cb242996db0c04604043408d6e545cf95%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636948485324627395&sdata=uqrLTp%2FotYCmTVLFSqtB3FSX%2BcloTd1pMw8ANWL4wPs%3D&reserved=0.
i have tried both. the first example is with the cmdexe and the second example is with the powershell type.
Russell Young
On Mon, Jun 3, 2019 at 7:44 AM Chris Lumnah notifications@github.com wrote:
Are you using the Powershell run type or the Operating system run type?
From: rwyoung01 notifications@github.com Sent: Thursday, May 30, 2019 5:28 PM To: rubrikinc/rubrik-scripts-for-powershell Cc: Subscribed Subject: [rubrikinc/rubrik-scripts-for-powershell] Export-RubrikDatabasejob pass json file in SQL Server Agent Job (#91)
When I use the following script in a SQL Agent job as a cmdshell script type
powershell.exe D:\Powershell\Rubrik\Export-RubrikDatabasejob.ps1 -Jobfile Export-RubrikDatabaseJobFile.json Nothing happens and I get the following message in the job history
The step did not generate any output. Process Exit Code 0. The step succeeded.
If I trying the script as a Powershell type D:\Powershell\Rubrik\Export-RubrikDatabasejob.ps1 -Jobfile Export-RubrikDatabaseJobFile.json
I get the following message
A job step received an error at line 177 in a PowerShell script. The corresponding line is ' } while ($RubrikRequestInfo.status -notin $ExitList) '. Correct the script and reschedule the job. The error information returned by PowerShell is: 'You must provide a value expression on the right-hand side of the '-' operator. '. Process Exit Code -1. The step failed.
The only way it will run is not passing the json file as a parm. Do you know what I am doing wrong
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub< https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Frubrikinc%2Frubrik-scripts-for-powershell%2Fissues%2F91%3Femail_source%3Dnotifications%26email_token%3DAFKMBSBJYXFMME3V3WYT67DPYBBJFA5CNFSM4HRL2OW2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4GW2J6QA&data=02%7C01%7C%7Cb242996db0c04604043408d6e545cf95%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636948485324617384&sdata=2N3GHn3rOKqfuPObP%2FW1Ed0yrjw4ay0lKDk0F3JcK4U%3D&reserved=0>, or mute the thread< https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAFKMBSG45G3PG6LW6J5OJSDPYBBJFANCNFSM4HRL2OWQ&data=02%7C01%7C%7Cb242996db0c04604043408d6e545cf95%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636948485324627395&sdata=uqrLTp%2FotYCmTVLFSqtB3FSX%2BcloTd1pMw8ANWL4wPs%3D&reserved=0
.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rubrikinc/rubrik-scripts-for-powershell/issues/91?email_source=notifications&email_token=AFZFZUHV5XWNRIQT2RNJELTPYUG3RA5CNFSM4HRL2OW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWZI3GQ#issuecomment-498240922, or mute the thread https://github.com/notifications/unsubscribe-auth/AFZFZUHVFK67A73U7VFY6ZTPYUG3RANCNFSM4HRL2OWQ .
I am setting up a lab to test this and fix another unrelated problem with this script. I will work on both at the same time and provide a solution.
From: rwyoung01 notifications@github.com Sent: Monday, June 3, 2019 9:14 AM To: rubrikinc/rubrik-scripts-for-powershell Cc: Chris Lumnah; Comment Subject: Re: [rubrikinc/rubrik-scripts-for-powershell] Export-RubrikDatabasejob pass json file in SQL Server Agent Job (#91)
i have tried both. the first example is with the cmdexe and the second example is with the powershell type.
Russell Young
On Mon, Jun 3, 2019 at 7:44 AM Chris Lumnah notifications@github.com wrote:
Are you using the Powershell run type or the Operating system run type?
From: rwyoung01 notifications@github.com Sent: Thursday, May 30, 2019 5:28 PM To: rubrikinc/rubrik-scripts-for-powershell Cc: Subscribed Subject: [rubrikinc/rubrik-scripts-for-powershell] Export-RubrikDatabasejob pass json file in SQL Server Agent Job (#91)
When I use the following script in a SQL Agent job as a cmdshell script type
powershell.exe D:\Powershell\Rubrik\Export-RubrikDatabasejob.ps1 -Jobfile Export-RubrikDatabaseJobFile.json Nothing happens and I get the following message in the job history
The step did not generate any output. Process Exit Code 0. The step succeeded.
If I trying the script as a Powershell type D:\Powershell\Rubrik\Export-RubrikDatabasejob.ps1 -Jobfile Export-RubrikDatabaseJobFile.json
I get the following message
A job step received an error at line 177 in a PowerShell script. The corresponding line is ' } while ($RubrikRequestInfo.status -notin $ExitList) '. Correct the script and reschedule the job. The error information returned by PowerShell is: 'You must provide a value expression on the right-hand side of the '-' operator. '. Process Exit Code -1. The step failed.
The only way it will run is not passing the json file as a parm. Do you know what I am doing wrong
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub< https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Frubrikinc%2Frubrik-scripts-for-powershell%2Fissues%2F91%3Femail_source%3Dnotifications%26email_token%3DAFKMBSBJYXFMME3V3WYT67DPYBBJFA5CNFSM4HRL2OW2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4GW2J6QA&data=02%7C01%7C%7Cb242996db0c04604043408d6e545cf95%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636948485324617384&sdata=2N3GHn3rOKqfuPObP%2FW1Ed0yrjw4ay0lKDk0F3JcK4U%3D&reserved=0>, or mute the thread< https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAFKMBSG45G3PG6LW6J5OJSDPYBBJFANCNFSM4HRL2OWQ&data=02%7C01%7C%7Cb242996db0c04604043408d6e545cf95%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636948485324627395&sdata=uqrLTp%2FotYCmTVLFSqtB3FSX%2BcloTd1pMw8ANWL4wPs%3D&reserved=0
.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rubrikinc/rubrik-scripts-for-powershell/issues/91?email_source=notifications&email_token=AFZFZUHV5XWNRIQT2RNJELTPYUG3RA5CNFSM4HRL2OW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWZI3GQ#issuecomment-498240922, or mute the thread https://github.com/notifications/unsubscribe-auth/AFZFZUHVFK67A73U7VFY6ZTPYUG3RANCNFSM4HRL2OWQ .
— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Frubrikinc%2Frubrik-scripts-for-powershell%2Fissues%2F91%3Femail_source%3Dnotifications%26email_token%3DAFKMBSGOA4KZ42GUETTJDCLPYUKMPA5CNFSM4HRL2OW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWZLNPQ%23issuecomment-498251454&data=02%7C01%7C%7Cd47c3165bee546b463de08d6e82573b5%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636951644880050253&sdata=L4G5TwBI8qLtSfCx2HErfmtGRsc0z9h%2F%2FsUvd0KeyZI%3D&reserved=0, or mute the threadhttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAFKMBSDKKAE6UJC4RNF23ADPYUKMPANCNFSM4HRL2OWQ&data=02%7C01%7C%7Cd47c3165bee546b463de08d6e82573b5%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636951644880060258&sdata=gHo%2BueqF7rArhb%2B9LhXPJCXcyl%2FIPHh3X1VgQ8jVSOw%3D&reserved=0.
I have learned that the Powershell type is running version 2.0 which does not support the 'notin' command because I am running SQL server 2012 R2. The cmdexe version is using powershell 3.0 but doesn't work. Hope this helps.
Russell Young
On Tue, Jun 4, 2019 at 8:22 AM Chris Lumnah notifications@github.com wrote:
I am setting up a lab to test this and fix another unrelated problem with this script. I will work on both at the same time and provide a solution.
From: rwyoung01 notifications@github.com Sent: Monday, June 3, 2019 9:14 AM To: rubrikinc/rubrik-scripts-for-powershell Cc: Chris Lumnah; Comment Subject: Re: [rubrikinc/rubrik-scripts-for-powershell] Export-RubrikDatabasejob pass json file in SQL Server Agent Job (#91)
i have tried both. the first example is with the cmdexe and the second example is with the powershell type.
Russell Young
On Mon, Jun 3, 2019 at 7:44 AM Chris Lumnah notifications@github.com wrote:
Are you using the Powershell run type or the Operating system run type?
From: rwyoung01 notifications@github.com Sent: Thursday, May 30, 2019 5:28 PM To: rubrikinc/rubrik-scripts-for-powershell Cc: Subscribed Subject: [rubrikinc/rubrik-scripts-for-powershell] Export-RubrikDatabasejob pass json file in SQL Server Agent Job (#91)
When I use the following script in a SQL Agent job as a cmdshell script type
powershell.exe D:\Powershell\Rubrik\Export-RubrikDatabasejob.ps1 -Jobfile Export-RubrikDatabaseJobFile.json Nothing happens and I get the following message in the job history
The step did not generate any output. Process Exit Code 0. The step succeeded.
If I trying the script as a Powershell type D:\Powershell\Rubrik\Export-RubrikDatabasejob.ps1 -Jobfile Export-RubrikDatabaseJobFile.json
I get the following message
A job step received an error at line 177 in a PowerShell script. The corresponding line is ' } while ($RubrikRequestInfo.status -notin $ExitList) '. Correct the script and reschedule the job. The error information returned by PowerShell is: 'You must provide a value expression on the right-hand side of the '-' operator. '. Process Exit Code -1. The step failed.
The only way it will run is not passing the json file as a parm. Do you know what I am doing wrong
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub<
.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub < https://github.com/rubrikinc/rubrik-scripts-for-powershell/issues/91?email_source=notifications&email_token=AFZFZUHV5XWNRIQT2RNJELTPYUG3RA5CNFSM4HRL2OW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWZI3GQ#issuecomment-498240922 , or mute the thread < https://github.com/notifications/unsubscribe-auth/AFZFZUHVFK67A73U7VFY6ZTPYUG3RANCNFSM4HRL2OWQ
.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub< https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Frubrikinc%2Frubrik-scripts-for-powershell%2Fissues%2F91%3Femail_source%3Dnotifications%26email_token%3DAFKMBSGOA4KZ42GUETTJDCLPYUKMPA5CNFSM4HRL2OW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWZLNPQ%23issuecomment-498251454&data=02%7C01%7C%7Cd47c3165bee546b463de08d6e82573b5%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636951644880050253&sdata=L4G5TwBI8qLtSfCx2HErfmtGRsc0z9h%2F%2FsUvd0KeyZI%3D&reserved=0>, or mute the thread< https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAFKMBSDKKAE6UJC4RNF23ADPYUKMPANCNFSM4HRL2OWQ&data=02%7C01%7C%7Cd47c3165bee546b463de08d6e82573b5%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636951644880060258&sdata=gHo%2BueqF7rArhb%2B9LhXPJCXcyl%2FIPHh3X1VgQ8jVSOw%3D&reserved=0
.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rubrikinc/rubrik-scripts-for-powershell/issues/91?email_source=notifications&email_token=AFZFZUDYG7S7MOMPTGLXZW3PYZUBRA5CNFSM4HRL2OW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODW4ROIY#issuecomment-498669347, or mute the thread https://github.com/notifications/unsubscribe-auth/AFZFZUG7MLWVFFJ37MOGWLTPYZUBRANCNFSM4HRL2OWQ .
ok, I moved the script to a SQL Server 2014 and have the SQL Agent job run as a Powershell Type and am passing the json file. So the issue is with SQL 2012 which runs Powershell 2.0.
Russell Young
On Tue, Jun 4, 2019 at 8:22 AM Chris Lumnah notifications@github.com wrote:
I am setting up a lab to test this and fix another unrelated problem with this script. I will work on both at the same time and provide a solution.
From: rwyoung01 notifications@github.com Sent: Monday, June 3, 2019 9:14 AM To: rubrikinc/rubrik-scripts-for-powershell Cc: Chris Lumnah; Comment Subject: Re: [rubrikinc/rubrik-scripts-for-powershell] Export-RubrikDatabasejob pass json file in SQL Server Agent Job (#91)
i have tried both. the first example is with the cmdexe and the second example is with the powershell type.
Russell Young
On Mon, Jun 3, 2019 at 7:44 AM Chris Lumnah notifications@github.com wrote:
Are you using the Powershell run type or the Operating system run type?
From: rwyoung01 notifications@github.com Sent: Thursday, May 30, 2019 5:28 PM To: rubrikinc/rubrik-scripts-for-powershell Cc: Subscribed Subject: [rubrikinc/rubrik-scripts-for-powershell] Export-RubrikDatabasejob pass json file in SQL Server Agent Job (#91)
When I use the following script in a SQL Agent job as a cmdshell script type
powershell.exe D:\Powershell\Rubrik\Export-RubrikDatabasejob.ps1 -Jobfile Export-RubrikDatabaseJobFile.json Nothing happens and I get the following message in the job history
The step did not generate any output. Process Exit Code 0. The step succeeded.
If I trying the script as a Powershell type D:\Powershell\Rubrik\Export-RubrikDatabasejob.ps1 -Jobfile Export-RubrikDatabaseJobFile.json
I get the following message
A job step received an error at line 177 in a PowerShell script. The corresponding line is ' } while ($RubrikRequestInfo.status -notin $ExitList) '. Correct the script and reschedule the job. The error information returned by PowerShell is: 'You must provide a value expression on the right-hand side of the '-' operator. '. Process Exit Code -1. The step failed.
The only way it will run is not passing the json file as a parm. Do you know what I am doing wrong
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub<
.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub < https://github.com/rubrikinc/rubrik-scripts-for-powershell/issues/91?email_source=notifications&email_token=AFZFZUHV5XWNRIQT2RNJELTPYUG3RA5CNFSM4HRL2OW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWZI3GQ#issuecomment-498240922 , or mute the thread < https://github.com/notifications/unsubscribe-auth/AFZFZUHVFK67A73U7VFY6ZTPYUG3RANCNFSM4HRL2OWQ
.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub< https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Frubrikinc%2Frubrik-scripts-for-powershell%2Fissues%2F91%3Femail_source%3Dnotifications%26email_token%3DAFKMBSGOA4KZ42GUETTJDCLPYUKMPA5CNFSM4HRL2OW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWZLNPQ%23issuecomment-498251454&data=02%7C01%7C%7Cd47c3165bee546b463de08d6e82573b5%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636951644880050253&sdata=L4G5TwBI8qLtSfCx2HErfmtGRsc0z9h%2F%2FsUvd0KeyZI%3D&reserved=0>, or mute the thread< https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAFKMBSDKKAE6UJC4RNF23ADPYUKMPANCNFSM4HRL2OWQ&data=02%7C01%7C%7Cd47c3165bee546b463de08d6e82573b5%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636951644880060258&sdata=gHo%2BueqF7rArhb%2B9LhXPJCXcyl%2FIPHh3X1VgQ8jVSOw%3D&reserved=0
.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rubrikinc/rubrik-scripts-for-powershell/issues/91?email_source=notifications&email_token=AFZFZUDYG7S7MOMPTGLXZW3PYZUBRA5CNFSM4HRL2OW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODW4ROIY#issuecomment-498669347, or mute the thread https://github.com/notifications/unsubscribe-auth/AFZFZUG7MLWVFFJ37MOGWLTPYZUBRANCNFSM4HRL2OWQ .
Please see this article on running powershell with sql agent.
https://www.sqlhammer.com/running-powershell-in-a-sql-agent-job/
For SQL Server 2012, i could get the script to run if i do the below as a job step powershell.exe -file E:\Scripts\Export-RubrikDatabasesJob.ps1
I had to modify the script to have this as the param section
param( $JobFile = "E:\Scripts\Export-RubrikDatabasesJobFile.json" )
I am going to test the functionality on other versions of SQL Server.
I was not able to run it on SQL 2012 because the Powershell type run version 2.0 and your code operator 'notin' is not supporter. But I was able to get it to run as CMDEXE but I had to code it this way
powershell.exe D:\Powershell\Rubrik\Export-RubrikDatabasejob.ps1 -jobfile d:\powershell\rubrik\Export-RubrikDatabaseJobFile.json
When I didn't specify the path to the json file it didn't do anything. So we can run it on 2012 when we upgrade powershell to 3.0 and run as CMDEXE.
Russell Young
On Wed, Jun 5, 2019 at 10:07 AM Chris Lumnah notifications@github.com wrote:
Please see this article on running powershell with sql agent.
https://www.sqlhammer.com/running-powershell-in-a-sql-agent-job/
For SQL Server 2012, i could get the script to run if i do the below as a job step powershell.exe -file E:\Scripts\Export-RubrikDatabasesJob.ps1
I had to modify the script to have this as the param section
param( $JobFile = "E:\Scripts\Export-RubrikDatabasesJobFile.json" )
I am going to test the functionality on other versions of SQL Server.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rubrikinc/rubrik-scripts-for-powershell/issues/91?email_source=notifications&email_token=AFZFZUDDYEISBTLHX4ZSK2DPY7JCLA5CNFSM4HRL2OW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXAANAY#issuecomment-499123843, or mute the thread https://github.com/notifications/unsubscribe-auth/AFZFZUCA5OIJXZSG3M4ZNQLPY7JCLANCNFSM4HRL2OWQ .
After some testing, I was able to confirm your way of running things.
For the version thing, there is not much I can do there due to the nature of what is supported as you can see from the blog post article.
Now that you have the script running, shall I close the issue as resolved?
From: rwyoung01 notifications@github.com Sent: Wednesday, June 5, 2019 2:36 PM To: rubrikinc/rubrik-scripts-for-powershell Cc: Chris Lumnah; Comment Subject: Re: [rubrikinc/rubrik-scripts-for-powershell] Export-RubrikDatabasejob pass json file in SQL Server Agent Job (#91)
I was not able to run it on SQL 2012 because the Powershell type run version 2.0 and your code operator 'notin' is not supporter. But I was able to get it to run as CMDEXE but I had to code it this way
powershell.exe D:\Powershell\Rubrik\Export-RubrikDatabasejob.ps1 -jobfile d:\powershell\rubrik\Export-RubrikDatabaseJobFile.json
When I didn't specify the path to the json file it didn't do anything. So we can run it on 2012 when we upgrade powershell to 3.0 and run as CMDEXE.
Russell Young
On Wed, Jun 5, 2019 at 10:07 AM Chris Lumnah notifications@github.com wrote:
Please see this article on running powershell with sql agent.
https://www.sqlhammer.com/running-powershell-in-a-sql-agent-job/
For SQL Server 2012, i could get the script to run if i do the below as a job step powershell.exe -file E:\Scripts\Export-RubrikDatabasesJob.ps1
I had to modify the script to have this as the param section
param( $JobFile = "E:\Scripts\Export-RubrikDatabasesJobFile.json" )
I am going to test the functionality on other versions of SQL Server.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rubrikinc/rubrik-scripts-for-powershell/issues/91?email_source=notifications&email_token=AFZFZUDDYEISBTLHX4ZSK2DPY7JCLA5CNFSM4HRL2OW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXAANAY#issuecomment-499123843, or mute the thread https://github.com/notifications/unsubscribe-auth/AFZFZUCA5OIJXZSG3M4ZNQLPY7JCLANCNFSM4HRL2OWQ .
— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Frubrikinc%2Frubrik-scripts-for-powershell%2Fissues%2F91%3Femail_source%3Dnotifications%26email_token%3DAFKMBSDZZ52Z7LXSXRRPJE3PZABT5A5CNFSM4HRL2OW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXAUCMY%23issuecomment-499204403&data=02%7C01%7C%7C5eb3c95f89814f630fbd08d6e9e4c497%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636953566090470044&sdata=oKluql%2FegEdtB1PE7UB0n3M1iCIvkmKD6q%2Foko1Y5SA%3D&reserved=0, or mute the threadhttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAFKMBSFVU2SZURALJ3OGKT3PZABT5ANCNFSM4HRL2OWQ&data=02%7C01%7C%7C5eb3c95f89814f630fbd08d6e9e4c497%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636953566090480055&sdata=dqa0%2BFjuUKdyldlU7MdPufGnSdwYiMh6ynQ7FC%2BQHp8%3D&reserved=0.
yes, thanks for helping
Russell Young
On Wed, Jun 5, 2019 at 9:55 PM Chris Lumnah notifications@github.com wrote:
After some testing, I was able to confirm your way of running things.
For the version thing, there is not much I can do there due to the nature of what is supported as you can see from the blog post article.
Now that you have the script running, shall I close the issue as resolved?
From: rwyoung01 notifications@github.com Sent: Wednesday, June 5, 2019 2:36 PM To: rubrikinc/rubrik-scripts-for-powershell Cc: Chris Lumnah; Comment Subject: Re: [rubrikinc/rubrik-scripts-for-powershell] Export-RubrikDatabasejob pass json file in SQL Server Agent Job (#91)
I was not able to run it on SQL 2012 because the Powershell type run version 2.0 and your code operator 'notin' is not supporter. But I was able to get it to run as CMDEXE but I had to code it this way
powershell.exe D:\Powershell\Rubrik\Export-RubrikDatabasejob.ps1 -jobfile d:\powershell\rubrik\Export-RubrikDatabaseJobFile.json
When I didn't specify the path to the json file it didn't do anything. So we can run it on 2012 when we upgrade powershell to 3.0 and run as CMDEXE.
Russell Young
On Wed, Jun 5, 2019 at 10:07 AM Chris Lumnah notifications@github.com wrote:
Please see this article on running powershell with sql agent.
https://www.sqlhammer.com/running-powershell-in-a-sql-agent-job/
For SQL Server 2012, i could get the script to run if i do the below as a job step powershell.exe -file E:\Scripts\Export-RubrikDatabasesJob.ps1
I had to modify the script to have this as the param section
param( $JobFile = "E:\Scripts\Export-RubrikDatabasesJobFile.json" )
I am going to test the functionality on other versions of SQL Server.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub < https://github.com/rubrikinc/rubrik-scripts-for-powershell/issues/91?email_source=notifications&email_token=AFZFZUDDYEISBTLHX4ZSK2DPY7JCLA5CNFSM4HRL2OW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXAANAY#issuecomment-499123843 , or mute the thread < https://github.com/notifications/unsubscribe-auth/AFZFZUCA5OIJXZSG3M4ZNQLPY7JCLANCNFSM4HRL2OWQ
.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub< https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Frubrikinc%2Frubrik-scripts-for-powershell%2Fissues%2F91%3Femail_source%3Dnotifications%26email_token%3DAFKMBSDZZ52Z7LXSXRRPJE3PZABT5A5CNFSM4HRL2OW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXAUCMY%23issuecomment-499204403&data=02%7C01%7C%7C5eb3c95f89814f630fbd08d6e9e4c497%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636953566090470044&sdata=oKluql%2FegEdtB1PE7UB0n3M1iCIvkmKD6q%2Foko1Y5SA%3D&reserved=0>, or mute the thread< https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAFKMBSFVU2SZURALJ3OGKT3PZABT5ANCNFSM4HRL2OWQ&data=02%7C01%7C%7C5eb3c95f89814f630fbd08d6e9e4c497%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636953566090480055&sdata=dqa0%2BFjuUKdyldlU7MdPufGnSdwYiMh6ynQ7FC%2BQHp8%3D&reserved=0
.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rubrikinc/rubrik-scripts-for-powershell/issues/91?email_source=notifications&email_token=AFZFZUCQC7RYENHKG7EHYQDPZB4D3A5CNFSM4HRL2OW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXBSQ5Q#issuecomment-499329142, or mute the thread https://github.com/notifications/unsubscribe-auth/AFZFZUGLPQ7BXVTQFY2NAV3PZB4D3ANCNFSM4HRL2OWQ .
When I use the following script in a SQL Agent job as a cmdshell script type
powershell.exe D:\Powershell\Rubrik\Export-RubrikDatabasejob.ps1 -Jobfile Export-RubrikDatabaseJobFile.json Nothing happens and I get the following message in the job history
The step did not generate any output. Process Exit Code 0. The step succeeded.
If I trying the script as a Powershell type
D:\Powershell\Rubrik\Export-RubrikDatabasejob.ps1 -Jobfile Export-RubrikDatabaseJobFile.json
I get the following message
A job step received an error at line 177 in a PowerShell script. The corresponding line is ' } while ($RubrikRequestInfo.status -notin $ExitList) '. Correct the script and reschedule the job. The error information returned by PowerShell is: 'You must provide a value expression on the right-hand side of the '-' operator. '. Process Exit Code -1. The step failed.
The only way it will run is not passing the json file as a parm. Do you know what I am doing wrong