PowerShell script exchange
Post Reply
matteu
Veeam Legend
Posts: 823
Liked: 128 times
Joined: May 11, 2018 8:42 am
Contact:

find Login for each managed server

Post by matteu »

Hello,

I would like to find each credentials for each managed server but I find it only for vcenter

ie : If I have vcenter server, I can find it with :

(Get-VBRServer -name "vcenter").GetSoapCreds().user

If I have linux, I can fint it with :
(Get-VBRCredentials | where {$_.id -eq $lin.GetSshCreds().credsid.guid}).name

How can I do for ESXi / scvmm / hyper-v ?

Thanks for your help.
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: find Login for each managed server

Post by jhoughes »

For ESXi and Hyper-V, you can use the FindDbCredentialsWithParent method.

I don't have an SCVMM host in our lab to confirm, but you should be able to pull it with one of the Find* methods.

ESXi:

Code: Select all

PS C:\Users\joe.houghes\Documents> $servers[0] | Select Name, Type

Name                          Type
----                          ----
adcseesx14.usdemo.veeam.local ESXi

PS C:\Users\joe.houghes\Documents> $servers[0].FindDbCredentialsWithParent()

Info                                  Id                                   Credentials
----                                  --                                   -----------
Veeam.Backup.Model.CDbCredentialsInfo 25ca4032-53ba-4f44-b058-60c05ea61ee9 Veeam.Backup.Common.CCredentials
Hyper-V:

Code: Select all

PS C:\Users\joe.houghes\Documents> $servers[-6] | Select Name, Type

Name            Type
----            ----
ATLHyperV01 HvServer

PS C:\Users\joe.houghes\Documents> $servers[-6].FindDbCredentialsWithParent()

Info                                  Id                                   Credentials
----                                  --                                   -----------
Veeam.Backup.Model.CDbCredentialsInfo 3a0e5ca4-9e01-46b4-a8fe-6d9dfd7039d2 Veeam.Backup.Common.CCredentials
Husband, Father, Solutions Architect, Geek | @DenverVMUG & @DenverPSUG leader | International Speaker | Veeam Vanguard | vExpert (PRO) | Cisco Champion
matteu
Veeam Legend
Posts: 823
Liked: 128 times
Joined: May 11, 2018 8:42 am
Contact:

Re: find Login for each managed server

Post by matteu »

Thank you for your answer.

Unfortunately, it doesn"t work for me :

Code: Select all

PS C:\Users\administrateur.PRODUCTION> $a=Get-VBRServer -Name "192.168.1.2"

PS C:\Users\administrateur.PRODUCTION> $a


Info               : 192.168.1.2 (VMware ESXi server)
ParentId           : 4d7ed677-2cdc-4286-a6ef-50cad6141109
Id                 : f058de4c-02f2-45e3-ad5e-64ea44df4e5b
Uid                : f058de4c02f245e3ad5e64ea44df4e5b
Name               : 192.168.1.2
Reference          : host-323
Description        : 
IsUnavailable      : False
Type               : ESXi
ApiVersion         : V672
PhysHostId         : f2b0d56e-fa22-4fca-b83d-5d9d69034fcc
ProxyServicesCreds : 




PS C:\Users\administrateur.PRODUCTION> $a.FindDbCredentialsWithParent()

PS C:\Users\administrateur.PRODUCTION>
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: find Login for each managed server

Post by jhoughes »

Try just .FindCredentials()
Husband, Father, Solutions Architect, Geek | @DenverVMUG & @DenverPSUG leader | International Speaker | Veeam Vanguard | vExpert (PRO) | Cisco Champion
matteu
Veeam Legend
Posts: 823
Liked: 128 times
Joined: May 11, 2018 8:42 am
Contact:

Re: find Login for each managed server

Post by matteu »

Same result

Code: Select all

PS C:\Users\administrateur.PRODUCTION> $a.FindCreds()

PS C:\Users\administrateur.PRODUCTION>
johan.h
Veeam Software
Posts: 723
Liked: 185 times
Joined: Jun 05, 2013 9:45 am
Full Name: Johan Huttenga
Contact:

Re: find Login for each managed server

Post by johan.h »

Are the hosts perhaps part of a cluster that you've already joined to VBR? The credentials would be stored there instead. For example, an ESXi host that is already joined to vCenter or a Hyper-V host that is part of a cluster may not return a value for FindCreds() - at least that is what happens for some of the servers in my environment.
matteu
Veeam Legend
Posts: 823
Liked: 128 times
Joined: May 11, 2018 8:42 am
Contact:

Re: find Login for each managed server

Post by matteu »

I don't have any cluster. It's only 1 vcenter + 1 esxi on this vcenter.

But I have 2 objects in my VBR. I have vcenter from one side and the ESXi on the other side. ESXi connection is done with root account on GUI. I would like to retrieve this information with powershell.
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: find Login for each managed server

Post by oleg.feoktistov »

Hi,

Try the methods below. Tested in v11.

For ESXi:

Code: Select all

$esxi = Get-VBRServer -Name 'esxi-01'
$esxiCreds = $esxi.GetSoapCreds()
Get-VBRCredentials | where {$_.Id -eq $esxiCreds.CredsId}
For Hyper-V:

Code: Select all

$hyperv = Get-VBRServer -Name 'hyper-v'
$hypervCreds = $hyperv.FindCreds()
Get-VBRCredentials | where {$_.Id -eq $hypervCreds.Id} 
Don't have SCVMM server in my lab, but I think FindCreds() method should be working on that server type as well.

Thanks,
Oleg
matteu
Veeam Legend
Posts: 823
Liked: 128 times
Joined: May 11, 2018 8:42 am
Contact:

Re: find Login for each managed server

Post by matteu »

Hello,

It doesn't work :(
I'm on V11 too

Code: Select all

PS C:\Users\administrateur.PRODUCTION> $esxi = Get-VBRServer -Name '192.168.1.2'
$esxiCreds = $esxi.GetSoapCreds()
Get-VBRCredentials | where {$_.Id -eq $esxiCreds.CredsId}

PS C:\Users\administrateur.PRODUCTION> $esxi


Info               : 192.168.1.2 (VMware ESXi server)
ParentId           : 4d7ed677-2cdc-4286-a6ef-50cad6141109
Id                 : f058de4c-02f2-45e3-ad5e-64ea44df4e5b
Uid                : f058de4c02f245e3ad5e64ea44df4e5b
Name               : 192.168.1.2
Reference          : host-323
Description        : 
IsUnavailable      : False
Type               : ESXi
ApiVersion         : V672
PhysHostId         : f2b0d56e-fa22-4fca-b83d-5d9d69034fcc
ProxyServicesCreds :
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: find Login for each managed server

Post by oleg.feoktistov »

Do $esxiCreds.User and $esxiCreds.CredsId contain any values upon GetSoapCreds() method invocation? Does $hyper.FindCreds() method work? Thanks!
matteu
Veeam Legend
Posts: 823
Liked: 128 times
Joined: May 11, 2018 8:42 am
Contact:

Re: find Login for each managed server

Post by matteu »

Nothing when I try
$esxiCreds.User -> nothing
$esxiCreds.CredsId -> I have
Guid
----
00000000-0000-0000-0000-000000000000

I don't understand why I don't see any credentials xD
matteu
Veeam Legend
Posts: 823
Liked: 128 times
Joined: May 11, 2018 8:42 am
Contact:

Re: find Login for each managed server

Post by matteu »

OK, I think I find my issue.

If I write Get-VBRServer | where {$_.type -eq "ESXi"} I have my ESX but in Veeam console it's not present as standalone ESXi. It's only present as ESXi attached to vcenter.
I can't add it as standalone ESX because veeam says me : Server already present.

Is it not possible to have ESXi as standalone if it's vcenter member and the vcenter is included as veeam vcenter server ?

I build new ESXi to test and add it to Veeam managed server and I can see credentials used with command :

Code: Select all

$ESXIServersManagedReq = Get-VBRServer | where {$_.type -eq "ESXi"}
 foreach ($ESXIServer in $ESXIServersManagedReq){
      $ESXIServer.GetSoapCreds().user
}
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: find Login for each managed server

Post by oleg.feoktistov »

Yes, that's the case. You can either add vCenter as a managed one with attached ESXi host or ESXi host as a standalone, even if it is a part of vCenter, but not both. Credentials are linked to a managed entity you added directly. Thanks!
matteu
Veeam Legend
Posts: 823
Liked: 128 times
Joined: May 11, 2018 8:42 am
Contact:

Re: find Login for each managed server

Post by matteu »

I can understand it but is it normal with get-vbrserver I can see the vcenter ESXi member ?
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: find Login for each managed server

Post by oleg.feoktistov » 1 person likes this post

Yes, it is implemented like that to allow other operations with child ESXis. For instance, choose them as a target for a VM Restore. Thanks!
matteu
Veeam Legend
Posts: 823
Liked: 128 times
Joined: May 11, 2018 8:42 am
Contact:

Re: find Login for each managed server

Post by matteu »

ok thank you :)
Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests