Posts

Showing posts from December, 2018

IIS Client Certificate Revocation Check Disable

Image
A couple of weeks back, a certificate was approaching it's expiration date on an IIS server and the update - although pretty straight forward, caused a major issue for the service running on that server.

I had the new certificate in PFX format, I've installed it on the computer certificate store and it was available in the IIS Manager console. All the certificates for the Root and Intermediate authorities were property installed and the clients had access to the CRL urls.

However, when I switched the certificate, the clients were not able to communicate property with the website. After going through the logs on the clients and the application, I discovered that the clients were using client certificates in order to authenticate and the validation process was failing for those certificates since my server could not check their revocation.

I opened up a command prompt to get more information on the bindings on the website since there are settings that are not available when usin…

Building a PowerShell cmdlet using C# - Part 2: Debugging

Image
On the previous article of the series, we created a Visual Studio project for a cmdlet and added the base code. This article is going to be about debugging the code, an ability that will greatly reduce the time taken to troubleshoot.

Right click your project and select "Properties". On the properties tab, click "Debug" to go to debug settings.


Here we are gong to select the "Start external program" option and browse to the powershell executable located at "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe". This way, when we start the debugger, a PowerShell window will start.

We also want our module to be loaded to that PowerShell host so fill the following in the "Command line arguments" box: -noexit -command "&{ import-module .\DemoCmdlet.dll -verbose}"

Replace the name of the dll with the one created for your project. You can find it by browsing to the bin/Debug folder in your project.


When you hit "Start&…

Building a PowerShell cmdlet using C# - Part 1: Basic Code and Requirements

Image
As PowerShell evolved, it gave administrators more are more options when creating functions. The latest addition in PowerShell 5 was classes which along with the ability to use .NET classes allows us to build functions for even the most complicated tasks.

The use of classes and .NET objects however is much easier in C# and the fact that the code is faster and strongly typed makes C# a better choice when building complicated functions. In this article, we are going to create a cmdlet using Visual Studio. Let's get started!

Fire up Visual Studio and create a Class Library project:


When the project is created, it will contain a class file that is going to hold the code for our cmdlet.


Before starting to write the code, we have to add a package that will provide all the necessary tools to create the cmdlet. Right click the solution in the Solution Explorer and select "Manage NuGet Packages for Solution".


When the package manager tab has opened, click "Browse" and s…