How to get all certificates in the Server Certificates section of IIS Manager programmatically (PowerShell)

Hi all, The certificates in the Server Certificates section of IIS Manager (inetmgr.exe) are certificates located in MY certificate store of the local machine, and their Enhanced Key Usage is Server Authentication. The following sample gets those certs: # Get all certs in MY store of Local Machine profile $store = New-Object System.Security.Cryptography.X509Certificates.X509Store(“My”,”LocalMachine”) $store.Open(“ReadOnly”) $store.Certificates…


How to install the response from a CA programmatically (PowerShell)

Hi all,   The other day a customer of mine was creating a SSL certificate request with IIS Manager (inetmgr.exe) with “Create Certificate Request…” action in the Server Certificates section. He was sending that request to a Certificate Authority, and he wanted to programmatically install the .cer file with the response from the CA the…


How to export issued certificates from a CA programatically (PowerShell)

Hi all,   The following sample is a conversion of How to export issued certificates from a CA programatically (C#) sample to PowerShell. It will get all the issued certs in the CA database and copy them to a folder:   #Params $strServer = “myserver”; $strCAName = “myserver-CA”; $strPathForCerts = “c:\test\”; # Constants $CV_OUT_BASE64HEADER = 0;…


We can’t manage printers with WMI in a clustered environment

Hi all,   Some time ago a customer of mine wanted to develop PowerShell scripts to manage printers in their clustered environment. They wanted to use WMI for that. The problem they found is that while they could list the printers on a stand-alone server by executing “get-wmi-object -class Win32_printer“, they didn’t get any result…


How to enumerate all certificates on a smart card (PowerShell)

Hi all,   Some time ago I assisted my colleague Jeff Bowles with the development of a PowerShell script which enumerates all certificates on a smart card. Basically the replacement to CAPICOM.Store.Open CAPICOM_SMART_CARD_USER_STORE. He developed a sample that returns a System.Security.Cryptography.X509Certificates.X509Store object with the certificates in the card. The sample tries to emulate what logonUI.exe does during smart…


Get-WmiObject : The type initializer for ‘System.Management.MTAHelper’ threw an exception

Hi all,   Sometime ago a customer of mine had some problems in his x64 machine when running WMI queries in Powershell. Take for instance the following query:  ” Get-WMIObject Win32_LogicalDisk ”   It failed with the following error: ” Get-WmiObject : The type initializer for ‘System.Management.MTAHelper’ threw an exception. At line:1 char:14 + Get-WMIObject…