Black Dynamite
Black Dynamite

Reputation: 4147

Powershell DSC: Run regular code in DSC

I have a DSC I am creating for web server configuration. My website will be using HTTPS, meaning that I have to have a certificate in a store. I don't see any modules designed to do this, so I was wondering how I could run regular Powershell functions in a DSC but keep the good parts of the DSC.

My workflow is as follows:

1 . Check if certificate exists

  1. If cert doesn't exist in the store, add it.

  2. If the cert does exist, grab the the Thumbprint to use in the xWeb xWebsite.BindingInfo.MSFT_xWebBindingInformation.CertificateThumbprint property.

As of now, I've got the code written to do the following actions, but I would still like to make use of the [DependsOn] functionality found in DSCs so I can handle any errors involved with creating/accessing the certificate.

Any help is greatly appreciated.

Upvotes: 1

Views: 234

Answers (1)

briantist
briantist

Reputation: 47772

https://serverfault.com/a/638926/236470

Use Microsoft's xCertificate module (with the xPfxImport resource) for this purpose.

Full disclosure: I wrote the original version of this resource (it's open source in Microsoft's repo now and has since had other contributors).


To answer your original question, you would use the Script resource to run arbitrary code without creating your own resource.

Upvotes: 3

Related Questions