sidbryd
Enthusiast
Enthusiast

Automating Creation of vCenter & VUM Database

Hi all,

I am in the process of trying to use powershell to deploy a VM, then install SQL, create ODBC connections, then install vCenter and VUM. This will all be on the same server.

I am stuck at the point where I need to write the part to create the databases for vCenter and VUM, using powershell. This is for vSphere 5.0.

Is anyone able to provide assistance?

Regards

Andrew

0 Kudos
3 Replies

Hi,

You can try the below command and the file to create the database for VC and VUM using powershell.

Write-Log "Creating Databases."

  Start-Process "C:\Program Files\Microsoft SQL Server\100\Tools\Binn\sqlcmd.exe" -ArgumentList "-S dc\SQLEXPRESS -i X:\Lab\DC\MakeDB.txt" -Wait

MakeDB.txt

Create Login vpx WITH PASSWORD = 'Password'

Go

create Database vCenter

Go

create database VUM

GO

ALTER AUTHORIZATION ON DATABASE::vCenter TO vpx

ALTER AUTHORIZATION ON DATABASE::VUM TO vpx

ALTER AUTHORIZATION ON DATABASE::msdb TO vpx

Go

EXEC master..sp_addsrvrolemember @loginame = '<DomainName>\VI-admin', @rolename = 'sysadmin'

Go

USE MASTER

GO

CREATE DATABASE RSA ON PRIMARY(

NAME='RSA_DATA',

FILENAME='C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\RSA_DATA.mdf',

SIZE=10MB,

MAXSIZE=UNLIMITED,

FILEGROWTH=10%),

FILEGROUP RSA_INDEX(

NAME='RSA_INDEX',

FILENAME='C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\RSA_INDEX.ndf',

SIZE=10MB,

MAXSIZE=UNLIMITED,

FILEGROWTH=10%)

LOG ON(

NAME='translog',

FILENAME='C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\translog.ldf',

SIZE=10MB,

MAXSIZE=UNLIMITED,

FILEGROWTH=10% )

GO

SP_DBOPTION 'RSA', 'autoshrink', true

GO

EXEC SP_DBOPTION 'RSA', 'trunc. log on chkpt.', true

GO

CHECKPOINT

GO

USE MASTER

GO

CREATE LOGIN RSA_DBA WITH PASSWORD = 'Password', DEFAULT_DATABASE = RSA

GO

CREATE LOGIN RSA_USER WITH PASSWORD = 'Password', DEFAULT_DATABASE = RSA

GO

USE RSA

GO

ALTER AUTHORIZATION ON DATABASE::RSA TO [RSA_DBA]

GO

CREATE USER RSA_USER FOR LOGIN [RSA_USER]

GO

CHECKPOINT

GO

Thanks

Please consider marking this answer "correct" or "helpful" if you found it useful.
sidbryd
Enthusiast
Enthusiast

Awesome, thank you I think this is 90% of the way there, I am trying to install SQL 2008 R2 Standard, not sql express though. What changes in the example given?

Regards

Andrew

0 Kudos

Though I haven't tried it with SQL 2008 R2 Standard but it should work with it too.

Please consider marking this answer "correct" or "helpful" if you found it useful.
0 Kudos