PowerShell script exchange
Post Reply
chrisBrindley
Enthusiast
Posts: 43
Liked: 3 times
Joined: Aug 21, 2013 1:15 pm
Contact:

Pull credentials from SQL database

Post by chrisBrindley »

Trying to determine if this is possible.

We are only allowed to store 1 admin account on a vm server, this account must have a password change every24 hours.
The way we do this is to have a service on the local machine create an an account and random a password on the account and enter this info to a sql database

I am trying to see if there is a way to pull a username password from this sql database that will be used to run indexing on the local vm, i know there is a tab under indexing in backup job where you can store the account, but if our password is changing everyday the job will fail.

We are not allowed to have service accounts on the servers as they are customer servers and we have audit requirements

So the script would have to pull the username and password and inject into the correct job.

Seems like a nightmare one to me

any help
nefes
Veeam Software
Posts: 643
Liked: 162 times
Joined: Dec 10, 2012 8:44 am
Full Name: Nikita Efes
Contact:

Re: Pull credentials from SQL database

Post by nefes »

Do you have a control over the script creating new admin user, or it is controlled by a customer?
If you have any point where you know username and password, you can create new credentials via Add-VBRCredentials and use that account for guest indexing in corresponding job via Set-VBRJobObjectVssOptions.
If you don't - please clarify at what point that user created and do you have any access to it?
chrisBrindley
Enthusiast
Posts: 43
Liked: 3 times
Joined: Aug 21, 2013 1:15 pm
Contact:

Re: Pull credentials from SQL database

Post by chrisBrindley »

I have access to everything
nefes
Veeam Software
Posts: 643
Liked: 162 times
Joined: Dec 10, 2012 8:44 am
Full Name: Nikita Efes
Contact:

Re: Pull credentials from SQL database

Post by nefes »

Then you can utilize something like that:

Code: Select all

## Enter your data here ##
$VMname = "name of VM to apply creds"
$user = "username"
$password = "password"
$jobname = "name of your job"
##########################
Add-PSSnapin VeeamPSSnapin
$today = Get-Date -DisplayHint Date -Format MM/dd/yy
$credentials = Add-VBRCredentials -User $user -Password $password -Description "Guest credentials for $VMname created at $today"
$job = Get-VBRJob -Name $jobname
$object = Get-VBRJobObject -Job $jobname -Name $VMname
Set-VBRJobObjectVssOptions -Object $object -Credentials $credentials
Please note that the script above is made for running on backup console. If you want to run it on the VM itself, you should utilize powershell remoting.
Also you can use Add-VBRCredentials -Credential $creds where $creds is object of System.Management.Automation.PSCredential type.
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Pull credentials from SQL database

Post by veremin »

In addition, if you’re on version 7, you can put into use newly-introduced “Credentials” cmdlets – Get-VBRCredentials; Set-VBRCredentials. Having account name and new password that should be assigned to it, you can simply use the following script that will change previously existed password:

Code: Select all

asnp VeeamPssnapin
Get-VBRCredentials -name "Name of account" | Set-VBRCredentials -password "New Password" 

Thanks.
Post Reply

Who is online

Users browsing this forum: No registered users and 20 guests