Posts archive for 2015

How to recover mdadm RAID array after superblock is zeroed

Few days ago I got one of my Linux RAID1 arrays go bad. One of the disks got bad sectors and the other one lost it’s superblock. So the array was degradated and the only one “good” disk was with bad sectors. I added a new disk and tried to sync the data but it stucked on 36%. Using tools like “dd” or “ddrescue” didn’t help neither. The “dd” just kept stopping and the “ddrescue” was recovering with 364Bytes/second so …

Read more

XSLT processor with PowerShell

Here is a simple way to transform XML document with specified XSL in PowerShell. It is easy achieavable using the System.Xml.Xsl namespace of the .NET.

PARAM
(
    [Parameter(Mandatory = $true)]
    [ValidateNotNullOrEmpty()]
    [String]$XmlPath,
     
    [Parameter(Mandatory = $true)]
    [ValidateNotNullOrEmpty()]
    [String]$XslPath,
     
    [Parameter(Mandatory = $true)]
    [ValidateNotNullOrEmpty()]
    [String]$HtmlOutput
)
 
try
{
    $XslPatht = New-Object System.Xml.Xsl.XslCompiledTransform
    $XslPatht.Load($XslPath)
    $XslPatht.Transform($XmlPath, $HtmlOutput)
     
    Write-Host "Generated output is on path: $HtmlOutput"
}
catch
{
    Write-Host $_.Exception -ForegroundColor Red
}

We pass the path to the XML file and the path to the …

Read more