Pull credentials from SQL database

PowerShell script exchange

Pull credentials from SQL database

Veeam Logoby chrisBrindley » Fri Sep 27, 2013 1:23 pm

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
chrisBrindley
Enthusiast
 
Posts: 43
Liked: 3 times
Joined: Wed Aug 21, 2013 1:15 pm

Re: Pull credentials from SQL database

Veeam Logoby nefes » Fri Sep 27, 2013 2:16 pm

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?
nefes
Veeam Software
 
Posts: 534
Liked: 125 times
Joined: Mon Dec 10, 2012 8:44 am
Full Name: Nikita Efes

Re: Pull credentials from SQL database

Veeam Logoby chrisBrindley » Fri Sep 27, 2013 4:52 pm

I have access to everything
chrisBrindley
Enthusiast
 
Posts: 43
Liked: 3 times
Joined: Wed Aug 21, 2013 1:15 pm

Re: Pull credentials from SQL database

Veeam Logoby nefes » Mon Sep 30, 2013 8:52 am

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.
nefes
Veeam Software
 
Posts: 534
Liked: 125 times
Joined: Mon Dec 10, 2012 8:44 am
Full Name: Nikita Efes

Re: Pull credentials from SQL database

Veeam Logoby v.Eremin » Mon Sep 30, 2013 11:55 am

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.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 4 guests