%3CLINGO-SUB%20id%3D%22lingo-sub-1128557%22%20slang%3D%22en-US%22%3EAutomated%20CA%20installs%20using%20VB%20script%20on%20Windows%20Server%202008%20and%202008R2%20%5BUPDATED%5D%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1128557%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSTRONG%3E%20First%20published%20on%20TECHNET%20on%20Sep%2018%2C%202009%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EStarting%20with%20Windows%20Server%202008%20the%20CA%20product%20team%20introduced%20a%20set%20of%20COM%20objects%20that%20can%20be%20used%20to%20control%20the%20installation%20of%20CAs.%20Using%20VBScript%20you%20can%20quickly%20automate%20the%20setup%20and%20installation%20of%20a%20CA.Below%20is%20a%20script%20that%20is%20being%20used%20by%20the%20product%20team%20in%20our%20testing%20of%20Certificate%20Services.%20SetupCA.vbs%20was%20designed%20to%20have%20the%20functionality%20present%20in%20the%20setup%20UI%20but%20in%20an%20easy%20command%20line%20that%20can%20be%20used%20in%20automation.%20Most%20of%20the%20functionality%20of%20the%20script%20is%20fairly%20straight%20forward%20in%20just%20setting%20properties%20on%20the%20setup%20object.%20A%20couple%20of%20features%2C%20like%20the%20key%2Fcert%20re-use%2C%20take%20a%20bit%20of%20code%20to%20get%20the%20setting%20right.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAll%20of%20the%20ICertSrvSetup%20COM%20object%20properties%20and%20methods%20are%20documented%20in%20the%20MSDN%20at%20%3CA%20title%3D%22http%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fbb736371%2528VS.85%2529.aspx%22%20href%3D%22http%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fbb736371%2528VS.85%2529.aspx%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%20http%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fbb736371%2528VS.85%2529.aspx%20%3C%2FA%3E%20.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20align%3D%22left%22%3EThe%20setup%20script%20is%20attached%20to%20this%20post%2C%20simply%20click%20the%20link%20for%20setupca.vbs%20and%20save%20the%20file%20to%20your%20local%20system.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESome%20example%20usages%20of%20the%20script%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EInstall%20Enterprise%20Root%20CA%20%3CBR%20%2F%3ECscript%20setupca.vbs%20%2Fie%20%2Fsn%20MyRootCA%20%2Fsk%204096%20%2Fsp%20%22RSA%23Microsoft%20Software%20Key%20Storage%20Provider%22%20%2Fsa%20SHA256%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EInstall%20Standalone%20Sub%20CA%20%3CBR%20%2F%3ECscript%20setupca.vbs%20%2Fit%20%2Fsn%20MySubCA%20%2Fsr%20MyParentCAMachine%5CMyRootCA%20%2Fsk%20384%20%2Fsp%20%22ECDSA_P384%23Microsoft%20Software%20Key%20Storage%20Provider%22%20%2Fsa%20SHA1%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EUninstall%20CA%3A%20%3CBR%20%2F%3ECscript%20setupca.vbs%20%2Fuc%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EInstall%20Web%20Pages%3A%20%3CBR%20%2F%3ECscript%20setupca.vbs%20%2Fiw%20%2Fsr%20MyParentCAMachine%5CMyRootCA%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThere%20is%20also%20a%20usage%20that%20lists%20all%20the%20parameters%20if%20you%20run%20the%20script%20without%20any%20arguments.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EUPDATE%3A%20Script%20has%20been%20updated%20to%20include%20option%20for%20offline%20requests%20using%20new%20%2FOR%20switch.%20Example%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20align%3D%22left%22%3EInstall%20Enterprise%20Sub%20CA%20saving%20request%20to%20a%20file%3A%3C%2FP%3E%0A%3CP%20align%3D%22left%22%3ECscript%20setupca.vbs%20%2Fif%20%2Fsn%20%22My%20Sub%20CA%22%20%2Fsp%20%22RSA%23Microsoft%20Software%20Key%20Storage%20Provider%22%20%2Fsk%204096%20%2For%20%22c%3A%5Ctemp%5Cca.req%22%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fmsdnshared.blob.core.windows.net%2Fmedia%2FTNBlogsFS%2Fprod.evol.blogs.technet.com%2Ftelligent.evolution.components.attachments%2F01%2F5386%2F00%2F00%2F03%2F28%2F19%2F75%2Fsetupca.vbs%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%20setupca.vbs%20%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1128557%22%20slang%3D%22en-US%22%3E%3CP%3EFirst%20published%20on%20TECHNET%20on%20Sep%2018%2C%202009%20Starting%20with%20Windows%20Server%202008%20the%20CA%20product%20team%20introduced%20a%20set%20of%20COM%20objects%20that%20can%20be%20used%20to%20control%20the%20installation%20of%20CAs.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1128557%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EPKI%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

First published on TECHNET on Sep 18, 2009

Starting with Windows Server 2008 the CA product team introduced a set of COM objects that can be used to control the installation of CAs. Using VBScript you can quickly automate the setup and installation of a CA.Below is a script that is being used by the product team in our testing of Certificate Services. SetupCA.vbs was designed to have the functionality present in the setup UI but in an easy command line that can be used in automation. Most of the functionality of the script is fairly straight forward in just setting properties on the setup object. A couple of features, like the key/cert re-use, take a bit of code to get the setting right.

 

All of the ICertSrvSetup COM object properties and methods are documented in the MSDN at http://msdn.microsoft.com/en-us/library/bb736371%28VS.85%29.aspx .

 

The setup script is attached to this post, simply click the link for setupca.vbs and save the file to your local system.

 

 

 

Some example usages of the script:

 

Install Enterprise Root CA
Cscript setupca.vbs /ie /sn MyRootCA /sk 4096 /sp "RSA#Microsoft Software Key Storage Provider" /sa SHA256

 

Install Standalone Sub CA
Cscript setupca.vbs /it /sn MySubCA /sr MyParentCAMachine\MyRootCA /sk 384 /sp "ECDSA_P384#Microsoft Software Key Storage Provider" /sa SHA1

 

Uninstall CA:
Cscript setupca.vbs /uc

 

Install Web Pages:
Cscript setupca.vbs /iw /sr MyParentCAMachine\MyRootCA

 

There is also a usage that lists all the parameters if you run the script without any arguments.

 

 

 

UPDATE: Script has been updated to include option for offline requests using new /OR switch. Example:

 

Install Enterprise Sub CA saving request to a file:

Cscript setupca.vbs /if /sn "My Sub CA" /sp "RSA#Microsoft Software Key Storage Provider" /sk 4096 /or "c:\temp\ca.req"

 

setupca.vbs