PowerShell script exchange
Post Reply
vrzops
Novice
Posts: 4
Liked: never
Joined: Sep 12, 2017 7:28 am
Full Name: David Haase
Contact:

Use VBR Credentials to connect to VI Server via PowerCLI?

Post by vrzops »

Hi *.

I would like to connect to my vCenter Server through PowerCLI using VBR credential manager. I tried something like this:

Code: Select all

$VisCredential = Get-VBRCredentials -Name foo@vsphere.local
Connect-VIServer -Server vcenter.example.org -Credential $VisCredential
No success. I wonder whether something like this is possible.?! I don't like to store cleartext or hashed vCenter credentials in a file on the VBR Server.

Maybe someone has another idea :wink:

Cheers
David
**** PRESS PLAY ON TAPE ****
jhoughes
Veeam Vanguard
Posts: 282
Liked: 113 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Castle Rock, CO
Contact:

Re: Use VBR Credentials to connect to VI Server via PowerCLI?

Post by jhoughes » 1 person likes this post

No, you could not pipe this directly as the object returned is not a standard PSCredential object used by the Credentials parameter of Connect-VIServer as seen here:

Veeam Credentials Object:

Code: Select all

Get-VBRCredentials -Name FSGLAB\jhoughes | Get-Member
TypeName: Veeam.Backup.PowerShell.Infos.CInternalCredentials
Connect-VIServer input (trimmed to relevant parameters):

Code: Select all

Connect-VIServer [-Server] <String[]> [-Credential <PSCredential>]
Also, you cannot just pull down the encrypted password from the database with the cmdlet, as the intention is not for Veeam to be a credentials database, but rather to maintain the necessary credentials for use by Veeam components.

You wouldn't want anyone with access to your Veeam environment to be able to gain access to any/all credentials stored within Veeam by just running Get-VBRCredentials.
Husband, Father, Solutions Architect, Geek | @DenverVMUG & @DenverPSUG leader | International Speaker | Veeam Vanguard | vExpert (PRO) | Cisco Champion
vrzops
Novice
Posts: 4
Liked: never
Joined: Sep 12, 2017 7:28 am
Full Name: David Haase
Contact:

Re: Use VBR Credentials to connect to VI Server via PowerCLI?

Post by vrzops »

Hi Joe,
You wouldn't want anyone with access to your Veeam environment to be able to gain access to any/all credentials stored within Veeam by just running Get-VBRCredentials.
That's a good hint. I think, I have to reconsider my strategy.

Thank's for clearing this up.

Cheers
David
**** PRESS PLAY ON TAPE ****
veremin
Product Manager
Posts: 20413
Liked: 2301 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Use VBR Credentials to connect to VI Server via PowerCLI?

Post by veremin » 1 person likes this post

Can you also tell me what you're trying to achieve? Just to query vSphere objects? If so, it can be achieved via VB&R cmdlets as well - check Find-VBRViEntity cmdlet, for instance. Thanks!
vrzops
Novice
Posts: 4
Liked: never
Joined: Sep 12, 2017 7:28 am
Full Name: David Haase
Contact:

Re: Use VBR Credentials to connect to VI Server via PowerCLI?

Post by vrzops »

Hi Vladimir,

thanks for your reply.

I would like to query VM tags from vCenter to dynamically add VMs with special tag combination to backup jobs.

Cheers
David
**** PRESS PLAY ON TAPE ****
jhoughes
Veeam Vanguard
Posts: 282
Liked: 113 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Castle Rock, CO
Contact:

Re: Use VBR Credentials to connect to VI Server via PowerCLI?

Post by jhoughes » 1 person likes this post

Sorry David, didn't think to ask if you were just trying to query information for the jobs.

You don't need additional credentials to do that, you can do that with the Veeam native cmdlets as they will utilize the existing connections built with the stored credentials.

Here's a quick example from my lab environment, using the following:

vCenter name: vcsa.veeamlab.local
Repository name: ReFS
Tag to be added to Veeam job: VeeamTagTest

Code: Select all

$vCenterServer = Get-VBRServer -Name 'ausvcenter.lab.fullstackgeek.net'
$Repository = Get-VBRBackupRepository -Name 'ReFS'
$VMwareTag = Find-VBRViEntity -Name 'VeeamTagTest' -Tags -Server $vCenterServer

$TagBackupJob = Add-VBRViBackupJob -Name 'Tag Backup Job' -Description 'Demo backup job for VMware tag created via script' -BackupRepository $Repository -Entity $VMwareTag
Here's what the tag and job object look like afterward:

Code: Select all

$VMwareTag

ConnHostId  : fdd958d1-0a04-410a-964f-0f8f9c13a5fe
Type        : Tag
Reference   : urn:vmomi:InventoryServiceTag:512c257c-4a66-4cce-9578-34bb8df48f4b:GLOBAL
TagQsId     : urn:vmomi:InventoryServiceTag:512c257c-4a66-4cce-9578-34bb8df48f4b:GLOBAL
Id          : fdd958d1-0a04-410a-964f-0f8f9c13a5fe_urn:vmomi:InventoryServiceTag:512c257c-4a66-4cce-9578-34bb8df48f4b:G
              LOBAL
Name        : VeeamTagTest
Path        : ausvcenter.lab.fullstackgeek.net\VeeamBackup (Tags for Backup Jobs)\VeeamTagTest (Job Tag for Veeam Backups)
Description : Job Tag for Veeam Backups


$TagBackupJob | Get-VBRJobObject | Format-Table -AutoSize

Name         Type    ApproxSize Location
----         ----    ---------- --------
VeeamTagTest Include 0.0 B      ausvcenter.lab.fullstackgeek.net\VeeamBackup (Tags for Backup Jobs)\VeeamTagTest (Job Tag for Veeam Backups)
Husband, Father, Solutions Architect, Geek | @DenverVMUG & @DenverPSUG leader | International Speaker | Veeam Vanguard | vExpert (PRO) | Cisco Champion
vrzops
Novice
Posts: 4
Liked: never
Joined: Sep 12, 2017 7:28 am
Full Name: David Haase
Contact:

Re: Use VBR Credentials to connect to VI Server via PowerCLI?

Post by vrzops »

Hi Joe,

thank you for your help. That was what I have been looking for.
So there's no need to login to vCenter Server directly. Great :D

Cheers
David
**** PRESS PLAY ON TAPE ****
jhoughes
Veeam Vanguard
Posts: 282
Liked: 113 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Castle Rock, CO
Contact:

Re: Use VBR Credentials to connect to VI Server via PowerCLI?

Post by jhoughes »

Glad to hear that it helps. Let us know if you run into more problems or need more assistance with anything.
Husband, Father, Solutions Architect, Geek | @DenverVMUG & @DenverPSUG leader | International Speaker | Veeam Vanguard | vExpert (PRO) | Cisco Champion
Post Reply

Who is online

Users browsing this forum: No registered users and 18 guests