PowerShell script exchange
Post Reply
Tobias_Elfstrom
Enthusiast
Posts: 84
Liked: 8 times
Joined: Jul 04, 2012 6:32 am
Full Name: Tobias Elfstrom
Contact:

Enterprise Manager Powershell?

Post by Tobias_Elfstrom »

Hello.
Are there any powershell-hooks into Enterprise manager?

For example when you use Enterprise manager you can click on the "VMs" tab and get a very nice list of all backed up VM all your connected Veeam servers know about (see picture). I'd like to do this from powershell instead. That is get a a list of every VM with name, backup server, job name, restore points, location of the backup and the last date it run successfully.

I could probably go see what is happening on the SQL side of things and just do raw SQL queries to the Enterprise Manager Database but then if some future updates changes the Database scheme or whatever I will have to update my scripts..

Image

BR Tobias
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Enterprise Manager Powershell?

Post by veremin »

Are there any powershell-hooks into Enterprise manager?
Unfortunately, there are none.

However, as far as I can understand, the following script should provide quite a similar view:

Code: Select all

asnp VeeamPSSnapin
Foreach ($Job in (Get-VBRJob | where {$_.JobType -eq "Backup"}))
{
  Foreach ($VM in $Job.GetViOijs())
  {
    Get-VBRBackup  -name $Job.name | Select-Object -Property ` 
`@{N="VM Name";E={$VM.name}}, 
`@{N="Job Name";E={$_.Name}} , 
`@{N="Restore Points";E={($_ | Get-VBRRestorePoint -name $VM.name | Measure-Object).count}}, 
`@{N="Path";E={$_.Info.DirPath}},
`@{N="Creation Time"; E={($_ | Get-VBRRestorePoint -name $VM.name| Sort-Object creationtime -Descending| Select-Object -First 1).creationtime}} 
`| Sort Name -Descending | Format-Table
  }
} 
I’ve decided to split the corresponding line with the ` sign for the purpose of convenience. So, don’t forget to put it away or, otherwise, the script will fail.

Thanks.
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Enterprise Manager Powershell?

Post by veremin »

Additionally, have you already known that RESTful Api will be implemented in the upcoming version of Veeam Backup and Replication. Using such functionality, you will be able to everything that you can do with Enterprise Manager UI; so, stay tuned.

Thanks.
Tobias_Elfstrom
Enthusiast
Posts: 84
Liked: 8 times
Joined: Jul 04, 2012 6:32 am
Full Name: Tobias Elfstrom
Contact:

Re: Enterprise Manager Powershell?

Post by Tobias_Elfstrom »

v.Eremin wrote: Unfortunately, there are none.
To bad, well hopefully sometime there will be.
v.Eremin wrote: However, as far as I can understand, the following script should provide quite a similar view:
Indeed you can run queries such as this against each backup server but the whole point of Enterprise Manager is to gain a single pane of view and not having to maintain a list of backup servers anywhere else. Thanks for your suggestion though.

BR Tobias.
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Enterprise Manager Powershell?

Post by veremin »

Yep, I’ve forgotten to mention, that you will have to run the aforesaid script against each backup server deployed in your environment. Probably, usage of invoke method should answer your requirements – so, kindly search this subforum for “remote PowerShell” key words.

Thanks.
Martin9700
Influencer
Posts: 17
Liked: 3 times
Joined: Nov 10, 2010 2:18 pm
Full Name: Martin Pugh
Location: Massachusetts
Contact:

Re: Enterprise Manager Powershell?

Post by Martin9700 »

While it's not EM level consolidation, you could certainly place all of the backup servers in their own OU and use Get-ADComputer to retrieve them all:

Code: Select all

ForEach ($Server in (Get-ADCompter -Searchbase ou=backupou,dc=domain,dc=com))
{   ...vladimir's code here...
}
Also, instead of piping into Format-Table you could pipe into Out-Gridview to get a dynamic look at the data. Or better yet just leave it as object output and then you could use this piece of code as a function for several other things (HTML reports, emailed reports, etc)
Martin
www.thesurlyadmin.com
@thesurlyadm1n
Tobias_Elfstrom
Enthusiast
Posts: 84
Liked: 8 times
Joined: Jul 04, 2012 6:32 am
Full Name: Tobias Elfstrom
Contact:

Re: Enterprise Manager Powershell?

Post by Tobias_Elfstrom »

If one where to but the backup server with one OU one could most likely do it in such a way yes.
And just to clarify if someone actually tries to do what the VMs tab in Enterprise Manager shows it is worth to mention that Vladimirs example code does not produce the same output information and i would believe that it is only provided as an inspiration where to start.

I will wait until v7 and use the RESTful Api to be able to work with the Enterprise Manager directly.

BR Tobias.
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Enterprise Manager Powershell?

Post by veremin »

Of course, it’s nothing but a tip of the iceberg and one’ll have to put some efforts in order to consolidate the data coming from different backup servers. Though, I’m interested in hearing what particular information, apart from corresponding backup server, you believe, lacks there.

Thanks.
Tobias_Elfstrom
Enthusiast
Posts: 84
Liked: 8 times
Joined: Jul 04, 2012 6:32 am
Full Name: Tobias Elfstrom
Contact:

Re: Enterprise Manager Powershell?

Post by Tobias_Elfstrom »

v.Eremin wrote:Of course, it’s nothing but a tip of the iceberg and one’ll have to put some efforts in order to consolidate the data coming from different backup servers. Though, I’m interested in hearing what particular information, apart from corresponding backup server, you believe, lacks there.

Thanks.
Sure, the missing parts are only:
* In your example you make a selection for only backup jobs where as in the VMs tab you get replicas as well
* last successful backup (in your example you take out the oldest run on the job and you only need to change select-object -Last to -First to get the latest restore point, not sure if you need to verify that it is an actual successful restore point)
* backup location (repository if backup) (you have file path but since we do not know on what server this is its only part of the information :)) I would guess you can get this information by looking at the StorageID.
Vitaliy S.
VP, Product Management
Posts: 27055
Liked: 2710 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Enterprise Manager Powershell?

Post by Vitaliy S. »

Tobias_Elfstrom wrote:That is get a a list of every VM with name, backup server, job name, restore points, location of the backup and the last date it run successfully.
Tobias_Elfstrom wrote:* In your example you make a selection for only backup jobs where as in the VMs tab you get replicas as well
* last successful backup (in your example you take out the oldest run on the job and you only need to change select-object -Last to -First to get the latest restore point, not sure if you need to verify that it is an actual successful restore point)
* backup location (repository if backup) (you have file path but since we do not know on what server this is its only part of the information :)) I would guess you can get this information by looking at the StorageID.
Don't want to hijack this thread, but do you have Veeam ONE (part of VBMS) deployed in your VI? Veeam ONE v7 will have a rich set of predefined report templates that should give you the information you need, so I suggest taking a look at this functionality once it is available.
Tobias_Elfstrom
Enthusiast
Posts: 84
Liked: 8 times
Joined: Jul 04, 2012 6:32 am
Full Name: Tobias Elfstrom
Contact:

Re: Enterprise Manager Powershell?

Post by Tobias_Elfstrom »

Vitaliy S. wrote: Don't want to hijack this thread, but do you have Veeam ONE (part of VBMS) deployed in your VI? Veeam ONE v7 will have a rich set of predefined report templates that should give you the information you need, so I suggest taking a look at this functionality once it is available.
I do not have Veeam One in any VI implementation we run but would I be able to work with powershell to trigger a report end get the report back as powershell objects in the v7 version?

I'm only interested here to get the data and pass it along to other systems, now I know I could get all of the data straight out of the SQL databases but I prefer not to and use something, such as powershell comandlets in order to to be too much affected by internal updates of the Veeam software.

BR Tobias
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Enterprise Manager Powershell?

Post by veremin »

In your example you make a selection for only backup jobs where as in the VMs tab you get replicas as well
Since in case of replication restore points are stored in VMware native format (snapshots), it might be worth putting into use PowerCLI in order to check corresponding information regarding them (count, creation time):

Code: Select all

asnp VeeamPSSnapin
asnp VMware.Vimautomation.core
Connect-VIServer -Server "vCenter" -User "User" -Password "Password"
Foreach ($Job in (Get-VBRJob | where {$_.JobType -eq "Replica"}))
{
  Foreach ($VM in ($Job | Get-VBRJobObject))
  { 
    $Snapshots = Get-Snapshot -vm (Get-VM -name $VM.name)
    Get-VM -name $VM.name | Select-Object -Property `
`@{N="VM Name";E={$VM.name}}, 
`@{N="Job Name";E={$Job.Name}}, 
`@{N="Restore Points";E={($Snapshots | Measure-Object).count}}, 
`@{N="Path";E={$VM.Info.Location}}, 
`@{N="Creation Time"; E={($Snapshots | Sort-Object created -Descending | select -First 1).Created.DateTime}}` 
`| Sort Name -Descending | Format-Table
  }
} 
last successful backup (in your example you take out the oldest run on the job and you only need to change select-object -Last to -First to get the latest restore point, not sure if you need to verify that it is an actual successful restore point)
Yep, there must have been a typo, I’ve fixed it already.
backup location (repository if backup) (you have file path but since we do not know on what server this is its only part of the information ) I would guess you can get this information by looking at the StorageID.
Assuming that you utilize some remote methods to connect to different servers, you’ll be able to combine the name of this server with the aforesaid path, and it, in its turn, will be a direct location of backup data (sever1.yourdomain.net -> D:\Repository#1, for instance).

Hope this helps.
Thanks.
Vitaliy S.
VP, Product Management
Posts: 27055
Liked: 2710 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Enterprise Manager Powershell?

Post by Vitaliy S. »

Tobias_Elfstrom wrote:I do not have Veeam One in any VI implementation we run but would I be able to work with powershell to trigger a report end get the report back as powershell objects in the v7 version?
If you're referring to some kind of API that can be used to get report data and pass it further, then in the upcoming version it will not be available. Can you please tell me where would you like to pass this data to? In v7 you can create reports with required parameters and then schedule them on daily/weekly/monthly basis.
Tobias_Elfstrom
Enthusiast
Posts: 84
Liked: 8 times
Joined: Jul 04, 2012 6:32 am
Full Name: Tobias Elfstrom
Contact:

Re: Enterprise Manager Powershell?

Post by Tobias_Elfstrom »

v.Eremin wrote: Since in case of replication restore points are stored in VMware native format (snapshots), it might be worth putting into use PowerCLI in order to check corresponding information regarding them (count, creation time):
Yes but then I would have to loop trough every vcenter server as well and well, it builds up into a lot of looping and keeping tabs on instead of just working with one instance of Veeam Enterprise Manager :)
v.Eremin wrote: Assuming that you utilize some remote methods to connect to different servers, you’ll be able to combine the name of this server with the aforesaid path, and it, in its turn, will be a direct location of backup data (sever1: D:\Repository#1, for instance).
Actually no, it won't. There is nothing saying that the path is local to the backup server. The path i relative to the server holding the repository and not the backup server it self therefor the need to look for the location.

BR Tobias.
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Enterprise Manager Powershell?

Post by veremin »

Hmm, then, what about combining information regarding repository mounted host, and its path; might be, indeed, what you’re looking for:

Code: Select all

asnp VeeamPSSnapin
Foreach ($Job in (Get-VBRJob | where {$_.JobType -eq "Backup"}))
{
  Foreach ($VM in $Job.GetViOijs())
  {
    Get-VBRBackup  -name $Job.name | Select-Object -Property `
`@{N="VM Name";E={$VM.name}}, 
`@{N="Job Name";E={$_.Name}}, 
`@{N="Restore Points";E={($_ | Get-VBRRestorePoint -name $VM.name | Measure-Object).count}}, 
`@{N="Repo Mounted Host";E={($_.findrepository().findmounthost().realname)}}, 
`@{N="Path";E={($_.findrepository().path)}},
`@{N="Creation Time"; E={($_ | Get-VBRRestorePoint -name $VM.name| Sort-Object creationtime -Descending| Select-Object -First 1).creationtime}} `
`| Sort Name -Descending | Format-Table
  }
}  
Yep, I know that it’s not that trivial; however, since this topic was created in PowerShell subforum, I have been trying to provide you with possible options of how this task can be achieved via PS.

Thanks.
Tobias_Elfstrom
Enthusiast
Posts: 84
Liked: 8 times
Joined: Jul 04, 2012 6:32 am
Full Name: Tobias Elfstrom
Contact:

Re: Enterprise Manager Powershell?

Post by Tobias_Elfstrom »

Vitaliy S. wrote: If you're referring to some kind of API that can be used to get report data and pass it further, then in the upcoming version it will not be available. Can you please tell me where would you like to pass this data to? In v7 you can create reports with required parameters and then schedule them on daily/weekly/monthly basis.
In this particular case I just want to insert the data into another SQL DB, a sort of CMDB.
And since I have all the data I need already in Enterprise manager I though that it would be nice if there was an official way of using powershell to grab it and just insert into my other DB rather than taking the data from the Veeam DB directly.
Tobias_Elfstrom
Enthusiast
Posts: 84
Liked: 8 times
Joined: Jul 04, 2012 6:32 am
Full Name: Tobias Elfstrom
Contact:

Re: Enterprise Manager Powershell?

Post by Tobias_Elfstrom »

v.Eremin wrote:Hmm, then, what about combining information regarding repository mounted host, and its path; might be, indeed, what you’re looking for:
Almost, that gave me the host where the repository was.. defined I guess but using:

Code: Select all

.FindRepository().findhost().realname
gave me the location of the actual repository.
v.Eremin wrote: Yep, I know that it’s not that trivial; however, since this topic was created in PowerShell subforum, I have been trying to provide you with possible options of how this task can be achieved via PS.
And I do appreciate your efforts.
I know I said I would wait until we get the REST against the Enterprise Manager's webinterface but now I think I will implement it like this as a workaround until that time comes.
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Enterprise Manager Powershell?

Post by veremin »

Glad to hear that you’ve finally nailed it down; and the RESTful API once released might, indeed, answer all the requirements you have. Thanks.
Post Reply

Who is online

Users browsing this forum: No registered users and 20 guests