PowerShell script exchange
Post Reply
jftuga
Enthusiast
Posts: 26
Liked: 2 times
Joined: Oct 22, 2010 7:02 pm
Full Name: John Taylor
Location: Athens, GA
Contact:

powershell documentation

Post by jftuga »

Where is the documentation for the powershell api? I want to create about 25 different jobs -- the only differences being the server that is getting backed up and the target directory. I figured it would be quicker to do this through PS rather than the GUI.

Also, any examples on how to do this would be greatly appreciated! :D

Thanks,
-John
jftuga
Enthusiast
Posts: 26
Liked: 2 times
Joined: Oct 22, 2010 7:02 pm
Full Name: John Taylor
Location: Athens, GA
Contact:

Re: powershell documentation

Post by jftuga »

OK, I found the PS documentation in the User Guide. I am still not sure where to start. I have Server 2008 R2 w/ PS version 2. I start powershell from the Start Menu, but none of the Get-VBR cmdlets seem to work. It says the command is not recognized as the name of cmdlet, function, or script file. Is there some special way that PS needs to be invoked in order for these cmdlets to work?

Thanks,
-John
jftuga
Enthusiast
Posts: 26
Liked: 2 times
Joined: Oct 22, 2010 7:02 pm
Full Name: John Taylor
Location: Athens, GA
Contact:

Re: powershell documentation

Post by jftuga »

OK, I just found out how to get this working. Within Veeam, Tools -> PowerShell. One more question, however. If I wanted to start a Veeam PS script from a batch file (that periodically ran from Task Scheduler), how would I invoke the PS script from within the batch file itself?
paul
Influencer
Posts: 13
Liked: 19 times
Joined: Jan 01, 2006 1:01 am
Contact:

Re: powershell documentation

Post by paul »

jftuga
Enthusiast
Posts: 26
Liked: 2 times
Joined: Oct 22, 2010 7:02 pm
Full Name: John Taylor
Location: Athens, GA
Contact:

Re: powershell documentation

Post by jftuga »

Hi Paul,

Please post something actually useful. For example, *which* PS script to run from the batch file. When you access the PS prompt from the GUI, it is unclear which PS script is invoked to get the Veeam cmdlets loaded. This is not mentioned in the User Guide either.

-John
Vitaliy S.
VP, Product Management
Posts: 27377
Liked: 2800 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: powershell documentation

Post by Vitaliy S. »

John, the syntax is fairly simple.

First of all you should add the line below to your_script.ps1. Please note that you should add this before executing any commands, as this line should register Veeam Snap-in in Powershell:

Code: Select all

Add-PSSnapin VeeamPSSnapIn
Then use Windows Scheduler to trigger you batch file, which will contain the line below:

Code: Select all

powershell.exe .\Your_script.ps1
Hope it helps!
Gostev
Chief Product Officer
Posts: 31814
Liked: 7302 times
Joined: Jan 01, 2006 1:01 am
Location: Baar, Switzerland
Contact:

Re: powershell documentation

Post by Gostev »

jftuga wrote:Please post something actually useful.
To be fair to Paul, he did answer the exact question that you have asked, so it is hard to call his response "not useful". :D
jftuga wrote:For example, *which* PS script to run from the batch file.
The one you wanted to run according to your 3rd post above? I don't understand this question...
jftuga wrote:When you access the PS prompt from the GUI, it is unclear which PS script is invoked to get the Veeam cmdlets loaded.
What do you mean? There is no script invoked when you open PS prompt - it is just a command prompt. Just like there is no script invoked when you open regular command prompt with cmd.exe - it is there for you to type in and execute the commands.

Loading Veeam cmdlet with the above command just adds "namespace" to your script (or PS prompt session for that matter), so that you can start calling Veeam PS commands in it.
jftuga wrote:This is not mentioned in the User Guide either.
Well, you really need to be looking at the PowerShell documentation for this kind of information, not at our VBR User Guide. Basically, we assume that anyone who wants to create PowerShell scripts with our extensions will have basic understanding of PowerShell.
jftuga
Enthusiast
Posts: 26
Liked: 2 times
Joined: Oct 22, 2010 7:02 pm
Full Name: John Taylor
Location: Athens, GA
Contact:

Re: powershell documentation

Post by jftuga »

This is how you pull up the Exchange Mgmt Shell:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -PSConsoleFile "C:\Program Files\Microsoft\Exchange Server\bin\exshell.psc1" -noexit -command ". 'C:\Program Files\Microsoft\Exchange Server\bin\Exchange.ps1'"

So I thought there was a ps1 file that needed to be loaded. My apologies for the confusion on my part.

-John
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests