Enterprise Manager Powershell?

PowerShell script exchange

Enterprise Manager Powershell?

Veeam Logoby Tobias_Elfstrom » Wed Aug 07, 2013 6:59 am

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
Tobias_Elfstrom
Enthusiast
 
Posts: 84
Liked: 8 times
Joined: Wed Jul 04, 2012 6:32 am
Full Name: Tobias Elfstrom

Re: Enterprise Manager Powershell?

Veeam Logoby v.Eremin » Wed Aug 07, 2013 8:31 am

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.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Enterprise Manager Powershell?

Veeam Logoby v.Eremin » Wed Aug 07, 2013 8:36 am

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.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Enterprise Manager Powershell?

Veeam Logoby Tobias_Elfstrom » Wed Aug 07, 2013 8:41 am

v.Eremin wrote:
Are there any powershell-hooks into Enterprise manager?

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.
Tobias_Elfstrom
Enthusiast
 
Posts: 84
Liked: 8 times
Joined: Wed Jul 04, 2012 6:32 am
Full Name: Tobias Elfstrom

Re: Enterprise Manager Powershell?

Veeam Logoby v.Eremin » Wed Aug 07, 2013 8:47 am

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.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Enterprise Manager Powershell?

Veeam Logoby Martin9700 » Wed Aug 07, 2013 10:45 am

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
Martin9700
Influencer
 
Posts: 17
Liked: 3 times
Joined: Wed Nov 10, 2010 2:18 pm
Location: Massachusetts
Full Name: Martin Pugh

Re: Enterprise Manager Powershell?

Veeam Logoby Tobias_Elfstrom » Wed Aug 07, 2013 10:57 am

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.
Tobias_Elfstrom
Enthusiast
 
Posts: 84
Liked: 8 times
Joined: Wed Jul 04, 2012 6:32 am
Full Name: Tobias Elfstrom

Re: Enterprise Manager Powershell?

Veeam Logoby v.Eremin » Wed Aug 07, 2013 11:15 am

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.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Enterprise Manager Powershell?

Veeam Logoby Tobias_Elfstrom » Wed Aug 07, 2013 11:39 am

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.
Tobias_Elfstrom
Enthusiast
 
Posts: 84
Liked: 8 times
Joined: Wed Jul 04, 2012 6:32 am
Full Name: Tobias Elfstrom

Re: Enterprise Manager Powershell?

Veeam Logoby Vitaliy S. » Wed Aug 07, 2013 11:49 am

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.
Vitaliy S.
Veeam Software
 
Posts: 19558
Liked: 1102 times
Joined: Mon Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov

Re: Enterprise Manager Powershell?

Veeam Logoby Tobias_Elfstrom » Wed Aug 07, 2013 12:03 pm

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
Tobias_Elfstrom
Enthusiast
 
Posts: 84
Liked: 8 times
Joined: Wed Jul 04, 2012 6:32 am
Full Name: Tobias Elfstrom

Re: Enterprise Manager Powershell?

Veeam Logoby v.Eremin » Wed Aug 07, 2013 1:55 pm

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.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Enterprise Manager Powershell?

Veeam Logoby Vitaliy S. » Wed Aug 07, 2013 2:13 pm

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.
Vitaliy S.
Veeam Software
 
Posts: 19558
Liked: 1102 times
Joined: Mon Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov

Re: Enterprise Manager Powershell?

Veeam Logoby Tobias_Elfstrom » Wed Aug 07, 2013 2:15 pm

v.Eremin wrote:
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):


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:
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: 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.
Tobias_Elfstrom
Enthusiast
 
Posts: 84
Liked: 8 times
Joined: Wed Jul 04, 2012 6:32 am
Full Name: Tobias Elfstrom

Re: Enterprise Manager Powershell?

Veeam Logoby v.Eremin » Wed Aug 07, 2013 2:40 pm

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.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Next

Return to PowerShell



Who is online

Users browsing this forum: No registered users and 3 guests