-
- Enthusiast
- Posts: 31
- Liked: 2 times
- Joined: Jun 20, 2013 1:00 pm
- Full Name: Colin
- Contact:
Task scheduler launching powershell script
I am trying to backup an Symantec Enterprise Vault server with Veeam. I need to launch a powershell script with task scheduler that puts the vault store into "backup mode" and then launch the veeam job.
My problem is this, if I launch the script manually, it works great. If I let task scheduler launch it, it never puts the server into backup mode, but it does kick off the veeam job.
The task runs as the veeam service account and it has permission to do what it needs to do in enterprise vault (if I run it manually in a powershell window launched as this user it works fine)
C:\Windows\system32\Windowspowershell\v1.0\powershell and then the argument is the path to the .ps1 script.
I know the script launches because it runs the veeam job.
Is there a way to make task scheduler run the script in whatever the way it runs if I do it manually. Doing it through task scheduler isn't doing something right as far as the enterprise vault part of the script goes.
Any insight would be much appreciated!
Thanks
My problem is this, if I launch the script manually, it works great. If I let task scheduler launch it, it never puts the server into backup mode, but it does kick off the veeam job.
The task runs as the veeam service account and it has permission to do what it needs to do in enterprise vault (if I run it manually in a powershell window launched as this user it works fine)
C:\Windows\system32\Windowspowershell\v1.0\powershell and then the argument is the path to the .ps1 script.
I know the script launches because it runs the veeam job.
Is there a way to make task scheduler run the script in whatever the way it runs if I do it manually. Doing it through task scheduler isn't doing something right as far as the enterprise vault part of the script goes.
Any insight would be much appreciated!
Thanks
-
- Veeam Software
- Posts: 649
- Liked: 170 times
- Joined: Dec 10, 2012 8:44 am
- Full Name: Nikita Efes
- Contact:
Re: Task scheduler launching powershell script
Do you use some Symantec-specific powershell commandlets? If yes, you should import corresponding module or snap-in.
It is also worth checking if the user starting your .ps1 file have the same permissions as the one running it manually.
You could also write output of your script into some log file to find out what errors are happening during its execution.
It is also worth checking if the user starting your .ps1 file have the same permissions as the one running it manually.
You could also write output of your script into some log file to find out what errors are happening during its execution.
-
- Enthusiast
- Posts: 31
- Liked: 2 times
- Joined: Jun 20, 2013 1:00 pm
- Full Name: Colin
- Contact:
Re: Task scheduler launching powershell script
Yes it does, I have installed the console needed to launch the commands via the veeam server. If I launch the same script outside of task scheduler, it works fine.nefes wrote:Do you use some Symantec-specific powershell commandlets? If yes, you should import corresponding module or snap-in.
It is also worth checking if the user starting your .ps1 file have the same permissions as the one running it manually.
You could also write output of your script into some log file to find out what errors are happening during its execution.
It is the same user account launching it manually as the one task scheduler is using.
How would I output the running of the script to a log file?
-
- Veeam Software
- Posts: 649
- Liked: 170 times
- Joined: Dec 10, 2012 8:44 am
- Full Name: Nikita Efes
- Contact:
Re: Task scheduler launching powershell script
You can call it from task scheduler like:
Also you may want to add some Write-Host commands to see, for example, values of key variables used to call your commandlets.
Code: Select all
powershell .\MyScript.ps1 > c:\output.txt
-
- Enthusiast
- Posts: 31
- Liked: 2 times
- Joined: Jun 20, 2013 1:00 pm
- Full Name: Colin
- Contact:
Re: Task scheduler launching powershell script
It appears that when it runs via task manager, it thinks that the Enterprise vault addin doesn't exist.nefes wrote:You can call it from task scheduler like:Also you may want to add some Write-Host commands to see, for example, values of key variables used to call your commandlets.Code: Select all
powershell .\MyScript.ps1 > c:\output.txt
Code: Select all
WARNING: The following errors occurred when loading console C:\Program Files
(x86)\Enterprise Vault\EVShell.psc1:
Cannot load Windows PowerShell snap-in
Symantec.EnterpriseVault.PowerShell.Snapin because of the following error: The
Windows PowerShell snap-in 'Symantec.EnterpriseVault.PowerShell.Snapin' is not
installed on this machine.
-
- Veeam Software
- Posts: 649
- Liked: 170 times
- Joined: Dec 10, 2012 8:44 am
- Full Name: Nikita Efes
- Contact:
Re: Task scheduler launching powershell script
So all you need is to load snap-in to the context of your script. Try to add
at the beginnig of your script. It should solve your problem.
Code: Select all
Add-PSSnapIn 'Symantec.EnterpriseVault.PowerShell.Snapin'
-
- Product Manager
- Posts: 20413
- Liked: 2302 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: Task scheduler launching powershell script
Additionally, does the whole script activity take place locally or the script has some “remote” parts, as well (trying to connect to remote computer, etc.)? Thanks.
-
- Enthusiast
- Posts: 31
- Liked: 2 times
- Joined: Jun 20, 2013 1:00 pm
- Full Name: Colin
- Contact:
Re: Task scheduler launching powershell script
I figured it out. I had read that I needed to use the 32bit powershell so I made the path to launch it c:\windows\system32\WindowsPowershell\v1.0
Changing the path to SYSWOW64 made the script launch with the add-in.
Changing the path to SYSWOW64 made the script launch with the add-in.
-
- Product Manager
- Posts: 20413
- Liked: 2302 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: Task scheduler launching powershell script
Thanks, Colin, for coming back and updating the topic with the found resolution; much appreciated.
-
- Enthusiast
- Posts: 31
- Liked: 2 times
- Joined: Jun 20, 2013 1:00 pm
- Full Name: Colin
- Contact:
Re: Task scheduler launching powershell script
No problem, I hope it saves the next guy an hour or so hehe
Can Veeam 7 launch this pre activity script or do I have to use task scheduler? I don't see any GUI options for a pre activity script.
Can Veeam 7 launch this pre activity script or do I have to use task scheduler? I don't see any GUI options for a pre activity script.
-
- Product Manager
- Posts: 20413
- Liked: 2302 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: Task scheduler launching powershell script
There is no “pre-activity” option available in the job settings. Though, you can create a Scheduled Task and launch everything within it (start pre-activity, then, execute a job). Thanks.
Who is online
Users browsing this forum: No registered users and 8 guests