MSPSS: is there life after the helpdesk?

sharing solutions to uncommon IT problems

Powershell: Web Service Monitoring

leave a comment »

Script: WebServiceInvokeTest
Synopsis: This script can consume any webservice and logs a message in the event log in case of success or failure.
The script can be amended in the if block to also return values to monitoring services (I use it for SCOM but it should work for other monitoring serivces as well.
If you want to integrate it with SCOM all you have to do is instantiate the bag before the if block and fill it with the result of the test (and return the bag at the end).
Server: Target server
URI: Path to the webservice
Method: The method you want to consume
Location: the XML path to the variable we check to see if the webservice is responsive
Success: The value of the variable that identifies a successful connection

Example: .\WebServiceInvokeTest.ps1 -server “YourServer-WebServiceHost” -URI “/WSPath/WSName.asmx” -method “WSMethod2Test” -location “FirstNode.SecondNode” -success “ReturnedValue4Success (i.e.: True)”

Author: Roberto Santoro
Date: 18/07/2014
param (
[string]$server = $(throw “-server is required.”),
[string]$URI = $(throw “-URI is required.”),
[string]$method = $(throw “-method is required.”),
[string]$location = $(throw “-location is required.”),
[string]$success = $(throw “-success is required.”)

New-EventLog –LogName Application –Source “MyScript” -ErrorAction SilentlyContinue

$URL = “http://” + $server + $URI

try {
$Proxy = New-WebServiceProxy -uri $URL -namespace WebServiceProxy -UseDefaultCredential

[xml]$xml1 = $Proxy.”$method”.invoke()

$result = Invoke-Expression “`$xml1.$location”

if($result -eq $success){
Write-EventLog –LogName Application –Source “MyScript” –EntryType Information –EventID 100 –Message “The webservice test on $URL was successful.`r`nThe XML returned was: $($xml1.InnerXml)”
else {
Write-EventLog –LogName Application –Source “MyScript” –EntryType Error –EventID 101 –Message “The webservice test on $URL returned an error. The XML returned was: $($xml1.InnerXml)”
Write-EventLog –LogName Application –Source “MyScript” –EntryType Error –EventID 101 –Message “The webservice test on $URL returned an error. Exception Message: $($_.Exception.Message)”


Written by zantoro

July 23, 2014 at 11:39 am

Posted in Powershell

Tagged with

Powershell: write in a Windows event log

leave a comment »


this is really quick post about a Powershell quibble I faced today.
Writing in an event log is very easy but if you want to have your own Source (and most of the times you want to do that) you have to create the source first.

New-EventLog –LogName Application –Source “My Script”
Write-EventLog –LogName Application –Source “My Script” –EntryType Information –EventID 100 –Message “A Message”

Unfortunately if you have already created the source, you’ll get an error when trying to create it again the second time: “New-EventLog : The “My Script” source is already registered on the “localhost” computer.”

Most sources on the internet suggest to check if the source exists by doing: if (!(Get-Eventlog -LogName Application -Source “My Script”)) {
This a bad idea because Powershell has to parse the entire event log to find out if the Source exists, resulting in a very loooong query.
Personally, given that the error is a not blocking one, I resolved to run the command New-EventLog anyway and use the -ErrorAction SilentlyContinue parameter to keep the error quiet (but you still get other errors).

New-EventLog –LogName Application –Source “My Script” -ErrorAction SilentlyContinue




Written by zantoro

July 18, 2014 at 11:29 am

Posted in Powershell

Tagged with

SSO for a website with mixed forms and basic authentication

leave a comment »


We have tried to achieve Single Sign-On for a while consolidating 3 of our websites into one. The challenge was that 1 website was using Forms based authentication (fed by Active Directory through Dotnetnuke), 1 with basic authentication and classic ASP and 1 is a document repository with basic authentication.

My first challenge was to enable cross-application authentication for all applications (ASP and .NET) hosted outside the DotNetNuke pool (but still in the same website).
Frankly I had never had to do this before and I was surprised by simplicity of it all:
All we need in this case is to have the same <machinekey> in the web.config of every web application.
The machinekey is the key that is used to encrypt the authentication cookie, having the same machinekey allows other applications to decrypt the same cookie and find out who the user is.
IIS by default generates the machinekey on the go, if you want to achieve SSO you will have to specify it explicitly in the web.config (you can generate the keys from many websites like

<machineKey validationKey=”yourvalidationkey” decryptionKey=”youdecryptkey” decryption=”3DES” validation=”SHA1″ />
<authentication mode=”Forms”>
<forms name=”whatever” protection=”All” timeout=”60″ cookieless=”UseCookies” />

Once I did this I could easily retrieve the username from an ASP.NET page (using User.Identity.Name).
On classic ASP (using Request.ServerVariables(“AUTH_USER”)) is also easy but I had to configure IIS to process requests coming for .asp through .NET Framework. In IIS7.5 this is easy if you use its integrated pipeline (application pool mode=integrated) but it is also possible to achieve with the classic mode.
I followed this article: Wildcard mapping
Obviously once you did all this, you will have to update your apps to retrieve the username from the variables above.

So, at this stage I was already quite happy as I had achieved SSO throughout all our web applications but still I couldn’t find a way to do the same for our document repository as it uses built in (i.e.: not adaptable) functionalities of IIS such as basic authentication coupled with NTFS security.
Then I started thinking that this could be achieved by developing my own isapi filter that would do the checking on NTFS on the user behalf.
On IIS7.5 isapi have been replaced by http handlers and http modules. What I needed was an HTTP module that would:

  • Decrypt the cookie and retrieve the user
  • Redirect to the login page if the user is not logged in
  • Check the NTFS effective permissions of the user against the file he’s trying to download
  • If he doesn’t have read rights, redirect the user to the “not authorised page”
  • If he does have read rights, let the request go (the download is actually operated under the application pool identity)

This would not only achieve SSO for the document repository but would also give the user a better experience as if he is missing rights, he is not presented with the never ending login prompts typical of basic authentication but he’s given a clear “not authorised” message.

Here is the code I’ve put together (wordpress doesn’t allow me to upload actual code files or text so I had to PDF it): ntfs_checker
You can either compile it into dll and put in the bin folder or rename it to .vb and put it in the app_code folder and add the following tags in the web.config:

<add name=”ntfs_checker” type=”ntfs_checker” />
<add key=”Domain” value=”AD_Domain_Netbios”/>
<add key=”LoginPage” value=”/login.aspx”/>
<add key=”NotAuthPage” value=”/NotAuthorized.aspx”/>

If anyone tries it out and finds new ways to improve it, please post it back.

P.S.: one little update: the application pool of the NTFS checker must run with 32-bit apps enabled or it won’t work.


Written by zantoro

March 22, 2014 at 10:10 pm

Ubuntu 13.10 stuck on initramfs on boot

leave a comment »

I finally decided to write my first Post. If it would be for my contribution so far, this would be the first one of the Blog. So… a big “thank you” goes to Roberto for “keeping it real”! I will promise I will contribute more from now on.

The problem I would like to talk about is a very “peculiar” issue I encountered yesterday evening when turning on my Ubuntu 13.10 x64 HP N40L Proliant micro-server via wake-on-lan: the booting process got stuck on an initramfs prompt, just after the following lines:

[    3.956857]  sdd: sdd1 sdd2 < sdd5 >
[    3.957496] sd 5:0:0:0: [sdd] Attached SCSI disk
[    3.977678]  sda: sda1
[    3.977713]  sdc: sdc1
[    3.978048] sd 4:0:0:0: [sdc] Attached SCSI disk
[    3.980252]  sdb: sdb1
[    3.980607] sd 1:0:0:0: [sdb] Attached SCSI disk
[    3.987741] sd 0:0:0:0: [sda] Attached SCSI disk
[    4.120846] bio: create slab <bio-1> at 1

It was clear from the beginning that the problem was a failure while mounting /root.

Initially I thought that the issue could be related to a hardware problem but it turned out to be some sort of fake signature on the boot disk.

It took me a while to figure out how to boot without having to reinstall the OS or loose data.

These are the steps I followed (note that my OS drive is installed on LVM so look elsewhere if your boot is stuck at initramfs AND you don’t have LVM on the boot disk):

  • Create an Ubuntu live USB and boot from that one
  • Select “Try Ubuntu”
  • Open a Terminal, become root and execute the following commands (execute and analyze the output of each command individually)
lvdisplay               #displays the logical volumes
modprobe dm-mod         #loads the device-mapper kernel module
lvm vgscan              #scan all disks for volume groups
lvm vgchange -ay        #activates the logical volumes
ls /dev/mapper          #lists /dev/mapper

Your logical volumes should now be listed by the above command. They should appear both in /dev/mapper/ and /dev/YourVolumeGroupName (it should be clear from the LV Name properties of the lvdisplay command above).

In my case I have 2 logical volumes:

  • [servername]-root
  • [servername]-swap

Run the below command on the logical volumes listed in /dev/mapper

fsck /dev/mapper/LogicalVolumeName    #runs a filesystem check on the unmounted volume

Fsck on the swap logical volume completed without errors.

Fsck on the root logical volume failed identifying the type as “silicon_medley_raid_member” (while it is ext4 instead).

Tried to force ext4 filesystem check with the below command and that runs without error:

fsck.ext4 /dev/mapper/[servername]-root    #runs an ext4 filesystem check on the unmounted volume

So the problem is that during the boot process, the logical volume that should be mounted as /root is detected as silicon_medley_raid_member instead of ext4. The boot is interrupted and the initramfs console is displayed to the user.

wipefs /dev/mapper/[servername]-root

The above command did show something similar to:

offset               type
0x438                ext4   [filesystem]
                     UUID:  3fb6d498-f2a3-4f12-af65-316896d37b24

0x4e1fffe60          silicon_medley_raid_member   [raid]

The offset for silicon_medley_raid_member seems to be quite high.

I don’t have any raid on the OS disk so I decided to get rid of the unwanted magic string with the following command:

wipefs -o 0x4e1fffe60 /dev/mapper/[servername]-root

The above command seems to have done the trick. Running an fsck command would properly detect the volume as ext4 and perform the filesystem check. Let’s wrap up!

  • Close the Terminal
  • Shut down Ubuntu
  • Remove the Ubuntu live USB
  • The system should now boot successfully

Unfortunately I wasn’t able to get to the root cause of the issue (i.e. how was the silicon_medley_raid_member signature added in the first place and what triggered it) but it seems that I am not the only one!



Written by kdceddj

March 20, 2014 at 11:37 pm

IIS6 – Classic ASP – Special characters being displayed as �

leave a comment »


I haven’t posted anything in a while maybe a bit because I got lazy and/or maybe because I’m thinking of writing a big article about my last experience in the Philippines and I can put my mind to it…

Anyway… today I fixed an unusual problem on one of our websites, it was displaying special characters (like the accented i “í” or the ©) as “�”.

I knew right away the problem was somehow due to the wrong charset being referenced in the page. Initially I thought it could be due to the hex string problem I already wrote about some time ago but I couldn’t find said string anywhere in the text.

Eventually I found out that the problem was caused by this line:
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″>

Removing the “; charset=utf-8” fixed the issue.



Written by zantoro

March 5, 2014 at 2:25 pm

Posted in IIS

Tagged with ,

DotNetNuke – Error during upgrade “A newer version of this package is already installed”

leave a comment »


When I tried to upgrade our DNN portal from 7.1.2 to 7.2.0 I got a blocking, very cryptic error: “Upgrade A newer version of this package is already installed”.

The error log showed the following lines:

01/12/2014 17:55:09 [INFO] DotNetNuke.Services.Upgrade.Upgrade Start InstallPackage:D:\MyWebsite\Install\Module\
01/12/2014 17:55:10 [ERROR] DotNetNuke.Services.Upgrade.Upgrade A newer version of this package is already installed – 7.1.2

The problem was that I had copied over the upgrade files without first deleting the old Install folder. In the install folder we had old modules alongside with the new modules.

Apparently the DNN Install/Upgrade routine tries to install all modules in the module folder without any particular order or rule. When it tried to install a very old version of the coremessanging module it prompted the error above.

Deleting the Install folder (best practice anyhow) fixes the problem.


Written by zantoro

January 13, 2014 at 9:19 am

Posted in DotNetNuke

Tagged with ,

[MySQL] – Old DB restored on MySQL – Error loading schema content (Error Code: 1548 Cannot load from mysql.proc. The table is probably corrupted)

leave a comment »

Just a quick post as I have had this problem and I couldn’t find a solution on Google.
I tried to restore an old MySQL database on my Windows 2008 R2 using Workbench 6.0.

The restore was successful, I could query the db via PHP but trying to open the schema via Workbench I would now get an error:
Error loading schema content
Error Code: 1548 Cannot load from mysql.proc. The table is probably corrupted

The fix is easy: go to the MySQL bin folder and run mysql_upgrade (-p to make it ask for the root password).


Written by zantoro

November 21, 2013 at 12:32 pm

Posted in MySQL