-
- Novice
- Posts: 4
- Liked: never
- Joined: Sep 09, 2020 7:34 am
- Full Name: Lasse Hastrup
- Contact:
Get report on a single VM
Hi guys,
I would like to get the following "attributes/values" for a specific Virtual Machine using PowerShell.
$vmName = 'xx'
Attributes to output:
MachineName
JobName(s)
RestorePoints
LastSuccess
Is this possible to achive using PowerShell?
To be honest i tried myself, but i wasnt able to figure it out.
Thanks in advance!
I would like to get the following "attributes/values" for a specific Virtual Machine using PowerShell.
$vmName = 'xx'
Attributes to output:
MachineName
JobName(s)
RestorePoints
LastSuccess
Is this possible to achive using PowerShell?
To be honest i tried myself, but i wasnt able to figure it out.
Thanks in advance!
-
- VP, Product Management
- Posts: 7081
- Liked: 1511 times
- Joined: May 04, 2011 8:36 am
- Full Name: Andreas Neufert
- Location: Germany
- Contact:
Re: Get report on a single VM
Please check out this one:
powershell-f26/script-to-list-all-vms-a ... 29124.html
powershell-f26/script-to-list-all-vms-a ... 29124.html
-
- Novice
- Posts: 4
- Liked: never
- Joined: Sep 09, 2020 7:34 am
- Full Name: Lasse Hastrup
- Contact:
Re: Get report on a single VM
Hi Andreas,
Yea, i found that article aswell, however it doesn't give me what i desire the outcome to be.
It seems I need to use 10 different functions to get the output i desire, because for some reason using PowerShell with Veeam should be complicated
Yea, i found that article aswell, however it doesn't give me what i desire the outcome to be.
It seems I need to use 10 different functions to get the output i desire, because for some reason using PowerShell with Veeam should be complicated
-
- Veeam Vanguard
- Posts: 282
- Liked: 113 times
- Joined: Apr 20, 2017 4:19 pm
- Full Name: Joe Houghes
- Location: Castle Rock, CO
- Contact:
Re: Get report on a single VM
Well, part of it is because of the detail that you are asking to find and your source information.
With a single VM, you are asking about a job object. However, even your VM jobs may not include VMs directly, but they may target folders, clusters, datastores, or tags.
To accurately get the list of restore points for a single VM and that detail, it is best to start with your backups.
You would gather the detail of which VMs are within the backups (plus job name and last success), and then get the associated restore points for the particular VM in that backup.
It's just that you are looking for a single VM to be the basis of your query, which either requires investigating every vSphere job object that isn't a VM directly, or starting with the backup data to determine the objects contained within a backup.
This is all easy, but there is no simple cmdlet to investigate from a single VM perspective.
With a single VM, you are asking about a job object. However, even your VM jobs may not include VMs directly, but they may target folders, clusters, datastores, or tags.
To accurately get the list of restore points for a single VM and that detail, it is best to start with your backups.
You would gather the detail of which VMs are within the backups (plus job name and last success), and then get the associated restore points for the particular VM in that backup.
It's just that you are looking for a single VM to be the basis of your query, which either requires investigating every vSphere job object that isn't a VM directly, or starting with the backup data to determine the objects contained within a backup.
This is all easy, but there is no simple cmdlet to investigate from a single VM perspective.
Husband, Father, Solutions Architect, Geek | @DenverVMUG & @DenverPSUG leader | International Speaker | Veeam Vanguard | vExpert (PRO) | Cisco Champion
-
- Novice
- Posts: 4
- Liked: never
- Joined: Sep 09, 2020 7:34 am
- Full Name: Lasse Hastrup
- Contact:
Re: Get report on a single VM
Thanks for responding.
Yea, i guess you're right. It's different functions for diffrent purposes. I had hoped that something like Find-VBRViEntity would do the trick.
Do you have any sample code that give me the desired output?
Yea, i guess you're right. It's different functions for diffrent purposes. I had hoped that something like Find-VBRViEntity would do the trick.
Do you have any sample code that give me the desired output?
-
- Veeam Software
- Posts: 2010
- Liked: 670 times
- Joined: Sep 25, 2019 10:32 am
- Full Name: Oleg Feoktistov
- Contact:
Re: Get report on a single VM
Hi Lasse,
If you are still looking for an example, here is one I composed from my old scripts.
It's a bit rough, so, please, amend anything if necessary:
Hope that helps,
Oleg
If you are still looking for an example, here is one I composed from my old scripts.
It's a bit rough, so, please, amend anything if necessary:
Code: Select all
# Pull backup by its name
$backup = Get-VBRBackup -Name 'BackupName'
$summary = @()
# Get objects in backup.
$objects = $backup.GetObjects()
$sessions = Get-VBRBackupSession -Name 'BackupName*'
# Query each object and get relevant restore points and last success date.
foreach($object in $objects) {
$rps = Get-VBRRestorePoint -Backup $backup -Name $object.Name
$taskSessionsTotal = @()
foreach($session in $sessions) {
$taskSessions = Get-VBRTaskSession -Session $session -Name $object.Name | where {$_.Status -eq 'Success'}
$taskSessionsTotal += $taskSessions
}
$lastSession = $taskSessionsTotal | select @{n='CompletionTimeLocal';e={$_.Info.Progress.StopTimeLocal}} -Last 1
# Construct a new object and add it to an empty $summary array.
$summary += $object | select @{n='MachineName';e={$object.Name}}, @{n='JobName';e={$backup.Name}}, @{n='RestorePoints';e={$rps.Id}}, @{n='LastSuccess';e={$lastSession.CompletionTimeLocal}}
}
# Get summary array with constructed objects.
$summary | fl
Oleg
-
- Novice
- Posts: 4
- Liked: never
- Joined: Sep 09, 2020 7:34 am
- Full Name: Lasse Hastrup
- Contact:
Re: Get report on a single VM
Thanks a lot!!
Who is online
Users browsing this forum: No registered users and 7 guests