PowerShell script exchange
Post Reply
scautey
Lurker
Posts: 2
Liked: never
Joined: Mar 06, 2023 2:01 pm
Contact:

GetGuestOsName

Post by scautey »

Hello, I was able to create a script (below) to get the information I want from Veeam backup server.
One very cool feature I want to work with is Veeam's ability to retrieve Guest OS name. I am able to get that information when querying a job's object and if the vm has gone through one run of its job, but not in any other case.

How can I get the Guest Os Name for any VM?
Like what can be seen from: Inventory > Virtual Infrastructure > Microsoft Hyper-V > Standalone Hosts (click on a host, wait for info: Guest OS column populated)

Using VBR 11 on Standalone Hyper-V Hosts exclusively. VBR v12 soon to be installed.

Code: Select all

# Get all Jobs from my Veeam backup server
$jobs = Get-VBRJob

# For each job gather information to report
$report = foreach ($job in $jobs) {

    # For each vm in each backup job
    $allMyBackedUpVms = Get-VBRJobObject -Job $job
    
    # For each vm in each backup job get some info
    foreach ($backedUpVm in $allMyBackedUpVms) {
        $gatherInfo = [PSCustomObject]@{
            BackedUpName    = $backedUpVm.Name
            BackedUpOsName  = $backedUpVm.GetObject().GuestInfo.GetGuestOsName()
            BackedUpFrom    = $backedUpVm.Location
            BackUpEstimSize = $backedUpVm.ApproxSizeString
        }

        # Which job this vm is member of
        $gatherInfo | Add-Member -MemberType NoteProperty -Name 'VeeamJobName' -Value $job.Name
        $gatherInfo
    }
}

# PowerShell view
$report |Out-GridView
ronnmartin61
Veeam Software
Posts: 441
Liked: 131 times
Joined: Mar 07, 2016 3:55 pm
Full Name: Ronn Martin
Contact:

Re: GetGuestOsName

Post by ronnmartin61 »

Correct. We won't determine the guest OS until we've begun to process at least one backup cycle. You may need to try the Hyper-V Powershell module.
scautey
Lurker
Posts: 2
Liked: never
Joined: Mar 06, 2023 2:01 pm
Contact:

Re: GetGuestOsName

Post by scautey »

Thank you for providing clarification, ronnmartin61.
However, I am a bit disappointed as I can still see some virtual machines' operating system names from Standalone Hosts in Inventory, even though they haven't gone through one cycle. Do you know of a good place to propose a feature request for the Veeam PowerShell snap-in?

It's unfortunate that the Hyper-V PowerShell module isn't helpful in this regard. Perhaps I'm not looking in the right place.
ronnmartin61
Veeam Software
Posts: 441
Liked: 131 times
Joined: Mar 07, 2016 3:55 pm
Full Name: Ronn Martin
Contact:

Re: GetGuestOsName

Post by ronnmartin61 »

Honestly I'm not sure what SDK we are using to pull the Hyper-V guest OS name in the VBR inventory view perhaps someone from engineering will comment. This is the proper venue to submit feature requests as these discussion boards are closely monitored by our product management staff...
david.domask
Veeam Software
Posts: 1226
Liked: 322 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: GetGuestOsName

Post by david.domask » 1 person likes this post

@scautey,

I think inventory view does a live look-up of the items from the Infrastructure. Try Find-VBRHvEntity and search for VMs and see if that works for your purposes. You can match the UUID property from that cmdlet to the same UUID value on VMs in jobs with:

$job = Get-VBRJob -name 'name of your job'
$Objects = Get-VBRJobObject -Job $job
$Objects.GetObject().Uuid

It's a little tricky, but should work.

The Find-VBR*Entity cmdlets can be a bit slow sometimes to fetch from the production environment, so I advise get all the VMs into an array first and check against that array.
David Domask | Product Management: Principal Analyst
Post Reply

Who is online

Users browsing this forum: No registered users and 16 guests