PowerShell script exchange
Post Reply
vraengmose
Influencer
Posts: 16
Liked: 2 times
Joined: Jun 18, 2019 9:46 am
Full Name: Thomas Trolle Vrøngmose
Contact:

How to list Credentials reference to job and VM's

Post by vraengmose »

Hi

I am looking a way to list credentials reference to a Job's and VM's. Any ideas how to do this in powershell?

Example :
I have credentials: Admin

like to list all jobs it references to. Backup file 01, Backup 04, and so on.

and also VM's where it is used on: VM SS-DC01, SDE-File012 and so on.

?
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: How to list Credentials reference to job and VM's

Post by veremin » 1 person likes this post

What particular credentials you're talking about? Reference to specific view or dialog might help. Thanks!
Vitaliy S.
VP, Product Management
Posts: 27377
Liked: 2802 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: How to list Credentials reference to job and VM's

Post by Vitaliy S. » 1 person likes this post

Hello Thomas,

If you need to list all credentials used in the jobs and have Veeam ONE, then "Job Configuration Dump" report might help here, as it returns all credentials used in your backup jobs.

Thank you!
vraengmose
Influencer
Posts: 16
Liked: 2 times
Joined: Jun 18, 2019 9:46 am
Full Name: Thomas Trolle Vrøngmose
Contact:

Re: How to list Credentials reference to job and VM's

Post by vraengmose »

Let me try again. :)

If i look in my "Manage Credentials" i have an account "\administrator" type "standard". This account is used to do "Guest Processing" on the a lot of backup jobs and in sum pr. VM Objects.
I would like powershell the reference the account "\administrator" has to the backup job in "Guest Processing and pr. VM object aswell.

possible?
veremin wrote: Aug 16, 2019 1:39 pm What particular credentials you're talking about? Reference to specific view or dialog might help. Thanks!
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: How to list Credentials reference to job and VM's

Post by veremin » 1 person likes this post

Check these scripts and ask for additional help, if needed. Thanks!
vraengmose
Influencer
Posts: 16
Liked: 2 times
Joined: Jun 18, 2019 9:46 am
Full Name: Thomas Trolle Vrøngmose
Contact:

Re: How to list Credentials reference to job and VM's

Post by vraengmose »

can't figure out how to use this script. :?

Code: Select all

Get-VBRCredentials | ?{$_.id -eq $job.VSSoptions.WinCredsId}
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: How to list Credentials reference to job and VM's

Post by veremin » 2 people like this post

Check this sample:

Code: Select all

Asnp VeeamPSSnapin
Foreach ($Job in ((Get-VBRJob) | where {$_.JobType -eq "Backup" -and $_.GetVSSOptions().AreWinCredsSet -eq "True"}))
{
$JobVSSOptions = $Job.GetVssOptions()
$Job | select @{N="Job Name";E={$_.Name}}, @{N="Credentials";E={(Get-VBRCredentials | where {$_.id -eq $JobVSSOptions.WinCredsId}).name}} | Format-Table
}
Thanks!
vraengmose
Influencer
Posts: 16
Liked: 2 times
Joined: Jun 18, 2019 9:46 am
Full Name: Thomas Trolle Vrøngmose
Contact:

Re: How to list Credentials reference to job and VM's

Post by vraengmose »

Yes her is something i can use. :-)
But i would like it the other way around. Credentials and then list the ref. it has to the job and VM.


Credentials Job Name
-------- -----------
Administrator Backup job 1
Backup job 2

Credentials VM Name
-------- -----------
Administrator VM_DC01
VM_File156
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: How to list Credentials reference to job and VM's

Post by veremin »

This is how you can find credentials that are set for individual VMs:

Code: Select all

Asnp VeeamPSSnapin
Foreach ($Job in ((Get-VBRJob) | where {$_.JobType -eq "Backup" -and $_.GetVSSOptions().AreWinCredsSet -eq $True}))
{
    Foreach ($Object in (Get-VBRJobObject -Job $Job | where {$_.VssOptions.AreWinCredsSet -eq $True}))
    {
    	$ObjectVSSOptions = $Object.VssOptions
   	$Object | select @{N="VM Name";E={$_.Name}}, @{N="Credentials";E={(Get-VBRCredentials | where {$_.id -eq $ObjectVSSOptions.WinCredsId}).name}} 
    }
}
Then, you will need to save results of first and second scripts to variables and compare variables to where similar credentials are used.

Thanks!
vraengmose
Influencer
Posts: 16
Liked: 2 times
Joined: Jun 18, 2019 9:46 am
Full Name: Thomas Trolle Vrøngmose
Contact:

Re: How to list Credentials reference to job and VM's

Post by vraengmose »

Hi Vermin

It's nearly there.

I would like to ad the credentials description as well And getting a output file in a CSV file. It was not possible for me to achieve this.
Can you help?

And what about a output where the credentials have references to a backup job?

Sorry for being so demanding.
tdewin
Veeam Software
Posts: 1818
Liked: 655 times
Joined: Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin
Contact:

Re: How to list Credentials reference to job and VM's

Post by tdewin »

well don't have the code but you could push it in array

Code: Select all

$array = @()
in the loop

Code: Select all

$array += ($Job | select @{N="Job Name";E={$_.Name}}, @{N="Credentials";E={(Get-VBRCredentials | where {$_.id -eq $JobVSSOptions.WinCredsId}).name}})
and then convert it to csv

Code: Select all

$array | convertto-csv
I don't have a vbr server now at hence but here is an example with processes

Code: Select all

$array = @()

$procs = Get-Process
foreach ($proc in $procs) {
 $array += ($proc | select id,name)
}

$array | ConvertTo-Csv
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: How to list Credentials reference to job and VM's

Post by veremin » 1 person likes this post

And to get credentials' description you need one additional column to the provided scripts:

Code: Select all

@{N="Description";E={(Get-VBRCredentials | where {$_.id -eq $ObjectVSSOptions.WinCredsId}).Description}}

For example,

Code: Select all

Asnp VeeamPSSnapin
Foreach ($Job in ((Get-VBRJob) | where {$_.JobType -eq "Backup" -and $_.GetVSSOptions().AreWinCredsSet -eq $True}))
{
    Foreach ($Object in (Get-VBRJobObject -Job $Job | where {$_.VssOptions.AreWinCredsSet -eq $True}))
    {
    	$ObjectVSSOptions = $Object.VssOptions
   	$Object | select @{N="VM Name";E={$_.Name}}, @{N="Credentials";E={(Get-VBRCredentials | where {$_.id -eq $ObjectVSSOptions.WinCredsId}).name}}, @{N="Description";E={(Get-VBRCredentials | where {$_.id -eq $ObjectVSSOptions.WinCredsId}).Description}}  
    }
}
Thanks!
albertwt
Veteran
Posts: 942
Liked: 53 times
Joined: Nov 05, 2009 12:24 pm
Location: Sydney, NSW
Contact:

Re: How to list Credentials reference to job and VM's

Post by albertwt »

Hi @vEremin,

The script no longer works due to the cmdlet being deprecated.

Error:

Code: Select all

WARNING: This cmdlet is no longer supported for computer backup jobs. Use "Get-VBRComputerBackupJob" instead.
--
/* Veeam software enthusiast user & supporter ! */
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: How to list Credentials reference to job and VM's

Post by oleg.feoktistov »

Hi,

The cmdlet is not deprecated as a whole. The warning just states that it is no longer supported for computer backup jobs.
It still works for other platforms like VMware or Hyper-V.
Besides, the script runs fine in my lab. Is there something in particular that doesn't work in your case?

Best regards,
Oleg
albertwt
Veteran
Posts: 942
Liked: 53 times
Joined: Nov 05, 2009 12:24 pm
Location: Sydney, NSW
Contact:

Re: How to list Credentials reference to job and VM's

Post by albertwt »

Hi @Oleg,

There is no result in the script posted above, and only the Deprecation warning showing.

Image

What I am after is the name of the backup jobs and their respective Credentials if it is used.
--
/* Veeam software enthusiast user & supporter ! */
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: How to list Credentials reference to job and VM's

Post by oleg.feoktistov » 1 person likes this post

Do you happen to run it against backup copy jobs, agent backup jobs, nas backup jobs or replica jobs? These jobs have types other than "Backup" and the script above would filter them out. Thanks!
albertwt
Veteran
Posts: 942
Liked: 53 times
Joined: Nov 05, 2009 12:24 pm
Location: Sydney, NSW
Contact:

Re: How to list Credentials reference to job and VM's

Post by albertwt »

Hi @Oleg,
Correct me if I'm wrong, but the Where-Object already filter the Backup job type.
So, I wonder if the code is deprecated or if there is any updated cmdlet that can return more accurate results?
--
/* Veeam software enthusiast user & supporter ! */
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: How to list Credentials reference to job and VM's

Post by oleg.feoktistov » 1 person likes this post

Hi @albertwt,

Correct. That's why I asked. Because if you run it against agent backup jobs or other types I mentioned, no output will be produced.
Also, there is no way to specify guest credentials on agent jobs level in VBR, you would use credentials you specified in protection groups instead.

If job types you run this script against is of Backup type and it targets VMware or Hyper-V platforms, the code should work.
If it doesn't work, I would advise to check it line by line and see where the variable gets nulled.

Thanks,
Oleg
albertwt
Veteran
Posts: 942
Liked: 53 times
Joined: Nov 05, 2009 12:24 pm
Location: Sydney, NSW
Contact:

Re: How to list Credentials reference to job and VM's

Post by albertwt »

Sure thing, thank you @oleg.feoktistov,

Regards,
--
/* Veeam software enthusiast user & supporter ! */
Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests