Remove all Cached folders from imagegen with powershell

by Damiaan Peeters 3. June 2015 22:08

UDPATE: read the comments for simple oneliners!

Sometimes you need to say goodbye to a good friend.  ImageGen served us very well.  But we made the switch to ImageProcessor some time ago.

The only thing, if you start to clean the media folder, are all the "Cached" folders.  To remove them we wrote a little powershell script to help us out.

$path = "C:\Projects\parentfoldertoclean"
cd $path

# delete Cached folders
get-childitem -Include Cached -Recurse -force | Remove-Item -Force –Recurse

# Delete any empty directories left behind after deleting the old files.
Get-ChildItem -Recurse -Force | Where-Object { $_.PSIsContainer -and (Get-ChildItem -Path $_.FullName -Recurse -Force | Where-Object { !$_.PSIsContainer }) -eq $null } | Remove-Item -Force -Recurse

How to install a FREE startssl certificate on your IIS 7.x

by Damiaan Peeters 12. March 2013 22:32

Updated 2013-06-17: Added information about bindings when hosting multiple sites


Today I had to install a renewed certificate for a HTTPS web server.  Here are the steps I followed.

Create (or reauthenticate) your account

  • go to and authenticate (or sign-up or use the express lane button).
  • This process involves entering a authentication code send to your e-mail address. 
  • Follow the procedure, everything is pretty straightforward.  Don’t forget to backup your certificate which is installed in your browser.  If you reinstall your pc, you will need this certificate to gain access to your account.

Do e-mail validations first

The first catch.  If you want to create a certificate for another domain.
First do a “email address validation” in the validations wizard for the domain you will be creating a certificate for.  If you want to create a certificate for, then first do an email validation for postmaster, hostmaster or  For the .com TLD you might have other possibilities also. 
If you did not validated this e-mail address, you won’t receive any verification codes on this e-mail address.

Create a certificate

If you follow all instructions on the “certificates wizard”.  If you let startssl generate your private key, you should have a at least the following files at hand

  • ssl.key (the encrypted private key)
  • ssl.crt (the certificate or public key)

The SSL.crt could be used on a windows server, but that would be only the public key.  For HTTPS you also need the private key, because you need to decrypt the encrypted data.  So you will need to link the private key and the certificate together as we will describe in the next steps. 

Decrypt private key

First go to the toolbox and click the “decrypt private key”.


Paste in the content of the ssl.key file, enter your password which you provided in the previous step.

You now have a DECRYPTED private key.  Copy this decrypted key.

Create Certificate for IIS

Now go to “Create PKCS#12” in the toolbox.  Paste the decrypted key in the first box (private key).  And paste the content of the ssl.crt file in the second box.  Provide a new password to protect the file you will be creating.


Click continue.


Now download the PFX and use this file to install the certificate on your IIS 7.0/7.5 or higher.

Install the certificate

Open Inetmgr (Internet Information Services – IIS Manager) and open the “server certificates” on server level.


Click the “IMPORT” button and supply the PFX you just created (and uploaded?).  You might not have the right file extension, but that is no problem.  Just choose *.* as file type, select the file.  Finish off with your password, before hitting return.

Redefine bindings of website

If you have only one HTTPS site running Go to your HTTPS site,

  • click “Bindings”
  • “Edit” the https (port 443) line
  • choose the right SSL certificate
  • hit “OK”,
  • and click the “Close” button


Bindings when hosting multiple sites

If you have multiple sites running on your website, you might want to set the binding headers for HTTPS.  This can be done using the command prompt (as administrator) using these two commands:

C:\Windows\system32>cd \windows\system32\inetsrv
C:\Windows\System32\inetsrv>appcmd set site /"<THESITENAME>" /+bindings.[protocol='https',bindingInformation='<MYIPADDRESS>:443:<WANTEDHOSTNAME>']


change the "<THESITENAME>", "<MYIPADDRESS>", "<WANTEDHOSTNAME>" to approprate value's.


If you want to verify that the certificate is there, open certmgr.msc


Hope it helped  Glimlach


If you want to add the certificate to an existing site, you might want to find out the APP id using :

netsh http show sslcert

so that you can add the certificate manually to the existing website  (you can find the cert hash using the "server certificates" in IIS)

netsh http add sslcert ipport= certhash=baf9926b466e8565217b5e6287c97973dcd54874 appid={ab3c58f7-8316-42e3-bc6e-771d4ce4b201}

Find that big database in SQL server

by Damiaan Peeters 10. January 2013 20:08

We have several SQL databases.  Each for each client website.  We also have a lot of servers running SQL server.  When you need to clean up space, you sometimes know that there is just one big database . 

sp_helpdb to the rescue! 


And when you add a database name to sp_help ‘my_db_name’
you get all the files too…



SQL | Sysadmin

Ever wondered when you installed windows

by Damiaan Peeters 13. August 2012 11:56

Thinking about the date when you reinstalled the last time your windows machine?  Pretty easy to find, if you know where to look.

Press Windows button + R, type CMD + [ENTER]


then type systeminfo (documented on technet) and hit the image.


Scroll up and look for “Original Install Date” (or boot time, or …)


Fix windows search and outlook 2010 indexing

by Damiaan Peeters 7. August 2012 14:50

So your outlook 2010 isn’t indexing anymore?  Windows Search Email Indexer in Outlook 2010 remains disabled? You don’t have enough time to find out what’s wrong?

Try the FixIt solution on Microsoft Support site!  To easy, don’t think, this is self healing windows stuff…

Remove Service Pack on Windows Server 2008 R2 (Compcln)

by Damiaan Peeters 4. December 2011 00:15

So you need to clean some valuble space on your harddrive.  One directory is probably the C:\Windows\winsxs directory which size is very big.  The SxS stands for Side by Side and keeps all dll’s for each version of each program.  (Or something like that…)

If you found on the net already that you need to use the compcln command on your windows 7 or windows 2008.  You are close – but no sigar.  On windows 2008 R2 the tool can not be found because it is part of Windows 2008 SP2. To clean you WinSxS direcory (or at least remove the service pack from the WinSxS) you can use the DISM command instead of complcln.

DISM stands for Deployment Image Servicing and Management tool.  Normally it is used to manage your WIM image, but you can use it on your current windows installation. 

Take care.  You will not be able to uninstall the service pack after you run this command!  It takes some time, so be patient.  I managed to recover 4,5 GB from my WinSxS folder.

C:\Windows\system32>dism /online /cleanup-image /spsuperseded /hidesp


I found this forum post on TechCenter to be pretty usefull in search of information on this problem.

Regain administrator access to your SQL EXPRESS 2008 (R2)

by Damiaan Peeters 27. March 2011 23:32

As I described earlier with a plain SQL server loosing access to your own SQL server or database is a very annoying problem.

The Problem

When starting the Azure Compute Emulator I got this error:

Creating database DevelopmentStorageDb20090919...
Cannot create database 'DevelopmentStorageDb20090919' : CREATE DATABASE permission denied in database 'master'.

One or more initialization actions have failed. Resolve these errors before attempting to run the storage emulator again. These errors can occur if SQL Server was installed by someone other than the current user. Please refer to for more details.

What this error means is:

  • I was using the useDevelopmentStorage=true parameter, so the emulator connects to the default sqlexpress instance (MACHINE\sqlexpress) on the pc. 
  • Once connected, he tried to create a new database

If SQL Express is not installed by the user your are working with.  The current user is NOT a sysadmin and can’t create any databases).  Adding yourself is neither a solution or enabling the SA user as you are not granted access to do so.

The Solution

Launch the “add self to SQL SysAdmin” script created by ward Beattie.

It saves you days of work and searching.

I highly encourage you to DOWNLOAD the script from the original location.  But just for reference and in case the script got deleted or moved, I added the complete script below.


@echo off
rem ****************************************************************************
rem    Copyright (c) Microsoft Corporation. All rights reserved.
rem    This code is licensed under the Microsoft Public License.
rem ****************************************************************************
rem CMD script to add a user to the SQL Server sysadmin role
rem Input:  %1 specifies the instance name to be modified. Defaults to SQLEXPRESS.
rem         %2 specifies the principal identity to be added (in the form "<domain>\<user>").
rem            If omitted, the script will request elevation and add the current user (pre-elevation) to the sysadmin role.
rem            If provided explicitly, the script is assumed to be running elevated already.
rem Method: 1) restart the SQL service with the '-m' option, which allows a single connection from a box admin
rem            (the box admin is temporarily added to the sysadmin role with this start option)
rem         2) connect to the SQL instance and add the user to the sysadmin role
rem         3) restart the SQL service for normal connections
rem Output: Messages indicating success/failure.
rem         Note that if elevation is done by this script, a new command process window is created: the output of this
rem         window is not directly accessible to the caller.
set sqlresult=N/A
if .%1 == . (set /P sqlinstance=Enter SQL instance name, or default to SQLEXPRESS: ) else (set sqlinstance=%1)
if .%sqlinstance% == . (set sqlinstance=SQLEXPRESS)
if /I %sqlinstance% == MSSQLSERVER (set sqlservice=MSSQLSERVER) else (set sqlservice=MSSQL$%sqlinstance%)
if .%2 == . (set sqllogin="%USERDOMAIN%\%USERNAME%") else (set sqllogin=%2)
rem remove enclosing quotes
for %%i in (%sqllogin%) do set sqllogin=%%~i
@echo Adding '%sqllogin%' to the 'sysadmin' role on SQL Server instance '%sqlinstance%'.
@echo Verify the '%sqlservice%' service exists ...
set srvstate=0
for /F "usebackq tokens=1,3" %%i in (`sc query %sqlservice%`) do if .%%i == .STATE set srvstate=%%j
if .%srvstate% == .0 goto existerror
rem elevate if <domain/user> was defaulted
if NOT .%2 == . goto continue
echo new ActiveXObject("Shell.Application").ShellExecute("cmd.exe", "/D /Q /C pushd \""+WScript.Arguments(0)+"\" & \""+WScript.Arguments(1)+"\" %sqlinstance% \""+WScript.Arguments(2)+"\"", "", "runas"); >"%TEMP%\addsysadmin{7FC2CAE2-2E9E-47a0-ADE5-C43582022EA8}.js"
call "%TEMP%\addsysadmin{7FC2CAE2-2E9E-47a0-ADE5-C43582022EA8}.js" "%cd%" %0 "%sqllogin%"
del "%TEMP%\addsysadmin{7FC2CAE2-2E9E-47a0-ADE5-C43582022EA8}.js"
goto :EOF
rem determine if the SQL service is running
set srvstarted=0
set srvstate=0
for /F "usebackq tokens=1,3" %%i in (`sc query %sqlservice%`) do if .%%i == .STATE set srvstate=%%j
if .%srvstate% == .0 goto queryerror
rem if required, stop the SQL service
if .%srvstate% == .1 goto startm
set srvstarted=1
@echo Stop the '%sqlservice%' service ...
net stop %sqlservice%
if errorlevel 1 goto stoperror
rem start the SQL service with the '-m' option (single admin connection) and wait until its STATE is '4' (STARTED)
rem also use trace flags as follows:
rem     3659 - log all errors to errorlog
rem     4010 - enable shared memory only (lpc:)
rem     4022 - do not start autoprocs
@echo Start the '%sqlservice%' service in maintenance mode ...
sc start %sqlservice% -m -T3659 -T4010 -T4022 >nul
if errorlevel 1 goto startmerror
set srvstate=0
for /F "usebackq tokens=1,3" %%i in (`sc query %sqlservice%`) do if .%%i == .STATE set srvstate=%%j
if .%srvstate% == .0 goto queryerror
if .%srvstate% == .1 goto startmerror
if NOT .%srvstate% == .4 goto checkstate1
rem add the specified user to the sysadmin role
rem access tempdb to avoid a misleading shutdown error
@echo Add '%sqllogin%' to the 'sysadmin' role ...
for /F "usebackq tokens=1,3" %%i in (`sqlcmd -S np:\\.\pipe\SQLLocal\%sqlinstance% -E -Q "create table #foo (bar int); declare @rc int; execute @rc = sp_addsrvrolemember '$(sqllogin)', 'sysadmin'; print 'RETURN_CODE : '+CAST(@rc as char)"`) do if .%%i == .RETURN_CODE set sqlresult=%%j
rem stop the SQL service
@echo Stop the '%sqlservice%' service ...
net stop %sqlservice%
if errorlevel 1 goto stoperror
if .%srvstarted% == .0 goto exit
rem start the SQL service for normal connections
net start %sqlservice%
if errorlevel 1 goto starterror
goto exit
rem handle unexpected errors
sc query %sqlservice%
@echo '%sqlservice%' service is invalid
goto exit
@echo 'sc query %sqlservice%' failed
goto exit
@echo 'net stop %sqlservice%' failed
goto exit
@echo 'sc start %sqlservice% -m' failed
goto exit
@echo 'net start %sqlservice%' failed
goto exit
if .%sqlresult% == .0 (@echo '%sqllogin%' was successfully added to the 'sysadmin' role.) else (@echo '%sqllogin%' was NOT added to the 'sysadmin' role: SQL return code is %sqlresult%.)

Configuration of MySQL 5.5 on Websitepanel

by Damiaan Peeters 11. March 2011 19:36

So I followed these steps to activate MySQL 5.5 on our websitepanel deployment.

The current version of Websitepanel (1.1.0) doesn’t support Mysql by default.  However, with a few small changes you can get the Mysql version 5.5 to work.

    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity name="MySql.Data" publicKeyToken="c567fc88969c44d" />
<bindingRedirect oldVersion="" newVersion="" />

  • Finally add and update the MySQL configuration in website panel.  These where the values I used
    • Internal Address:
    • MySQL Installation Folder: C:\Program Files\MySQL\MySQL Server 5.5
    • Database Browser Logon URL:
    • Root login: root
    • Root password: our root password

There is still a bug with deleting the database.  There are solutions available for this problem, but it’s not urgent for me.  So I didn’t tried it.

Account Lockout and Management Tools

by Damiaan Peeters 13. September 2010 14:54

Today i had some issues with a locked account.

I downloaded the account lockout tools from Microsoft Download Center. 

It includes several tools… 

Additional Account Information

There is a very interesting tool called “additional account info”. It gives more information about a user’s password.

Here you have a screenshot.


To see the “Additional Account Info” tab, register the AcctInfo.DLL. on the pc where you are using the MMC “Active Directory Users and Computers” snap-in.  (you might need to install the Administrative tools on your client pc if you don’t want to install the plug-in on your server)

Register the DLL

Use the following command :

regsvr32 %systemroot%\system32\acctinfo.dll

(change the path appropriately)


This is a pretty cool application.   It goes searching through all event logs of the Domain Servers.


Use the Menu Searches – Built-in Searches.  It saves you lot’s of time.  You will see that the servers, event id’s and types are automatically set.  The tool is not blasting fast, but it gathers all information from the selected servers and dumps it into text files.

Make sure you have the right permissions to do search the event logs on those servers.


To see the current “bad password count” status on all the domain controllers, launch the tool, choose File – Select Target.  Enter the right username, and you will see on which domain controller the bad password attempts have occurred.


Note to self

by Damiaan Peeters 22. June 2008 15:31

Defragment from time to time your disk.


(22% free space)

Certified Umbraco Master, Part of Umbraco Certified partner comm-it, .Net and Azure developer, seo lover. Magician in my spare time.

Month List