SCAPaoT

System Center, Automation, Powershell and other Thoughts

Archive for the ‘Windows 7’ Category

Error 19 (0×80070013) in Tasksequence

Did you ever saw a error 19 in a tasksequence for rolling out office 2010 or other apps with SCCM 2007 R3?

The error 19 is pointing towards “drive is read only” and the smsts.log looks that way:

In our case, the issue was pointing towards the office 2010 installation files, because it is installed using an cusomtized msp created with /admin argument.
And in there where several things in the msp pointing towards this direction like custom template stores and so on.

But Office wasn’t the culprit. All was caused by bitlocker.
Yes, bitlocker.

If you ask why bitlocker, here is the answer:
The files for the installation of office 2010 where cached for local deployment and support of roaming users.
The bitlocker GPO in the active directory domain was set to:
Deny write access to fixed drives not protected by BitLocker

As the tasksquence tries to store the data on the drive with the highest avaiable free space, the second partition was used.
But as the partition wasn’t encrypted yet, the creation of the _SMSTaskSequence folder failed with “drive is read only” error 19.

We have decided to submit a but report on this error as we couldn’t understand why the cache tries to place the files on a read only drive.

So, if anyone else stumbles on that, check you GPOs and as a best practise, apply the GPO after installation hast finished…

Documentation made easy – Convert Problem Step Recorder File to HTML

Since Windows 7 and Server 2008 the build in tool “Problem Step Recorder” can make screenshots automatically on every click that is made. It is perfect for building installation howto’s or any other kind of documentation. Yes, there are more powerfull tools on the market, but hey, its for free… 
Only problem is, the files that are delivered as zipped MHT-Files only. So only browsers can show them. You are not able to import them for editing directly into Microsoft Word.

So I decided to build a little parser script in Powershell that converts the mht files from psr.exe into its html-files and jpeg’s.

This script takes the filepath of the zipfile or the unzipped mht file and extracts the hmtl, css, and jpeg’s into a subfolder:

param($file=$(read-host "filename of psr-zip or psr-mht file? "))

function writefile($dir, $fname, $text)
{
    $text | out-file -append $dir\$fname -Encoding "default"
}

function convertJPG($dir)
{

$jpgfiles = get-item $dir\*.jpeg.txt
foreach($jpg in $jpgfiles)
    {
        $filename = $jpg.name.tostring()

        "$filename -> $($filename.substring(0,$filename.length-4))"

        [System.Convert]::FromBase64String((Get-Content $jpg -readcount 0)) | set-content -Encoding Byte "$dir\$($filename.substring(0,$filename.length-4))"
        remove-item $dir\$filename -force
    }   
}

function extractPSR($zipfile, $destfolder)
{
 $shellApplication = new-object -com shell.application
 $zip = $shellApplication.Namespace($zipfile)
 $dest = $shellApplication.Namespace($destfolder)
 $dest.copyhere($zip.Items())
}
if(test-path $file)
{
$file = get-item $file

$folder = (get-date -Format "yyyyMMddHHmmss").tostring()
$folderObject = new-item $folder -type directory -force
$filename = ""

if($file.name.tostring().tolower().endswith(".zip"))
{
 $unzipdest = "$($folderobject.fullname.tostring())\temp"
 new-item $unzipdest -type directory -force | out-null
 extractPSR $file.fullname $unzipdest
 $psrfile = get-item "$unzipdest\*.mht"
}
else
{
 $psrfiles = $file
}

$content = get-content $psrfile

"Start: creating files in folder $pwd\$folder"

foreach($line in $content)
{
  switch -wildcard ($line)
  {
    "Content-Location: *"
    {
        #$line
        $filename = $line.split(":")[1].trim()
         if($filename.tolower().endswith(".jpeg"))
         {
            "writing: $filename.txt"
         }
         else
         {
            "writing: $filename"
         }

        break;
    }
    "--=_NextPart_*" { break; }

    "Content-Type: *" { break; }

    "Content-Transfer-Encoding: base64" { break; }

    default
    {
        if($filename -ne "")
        {
            if($filename.tolower().endswith(".jpeg"))
            {
                if($line -ne "")
                {
                    writefile $folder "$filename.txt" $line
                }
            }
            else
            {

                writefile $folder $filename $line
            }
        }
        break
    }

  }

}
"Finished: Creating files"
"Start: converting pictures from text to JPG"

convertJPG $folder
"Finished: converting pictures"

$yesno = read-host "Open containing folder? [y] "

if($yesno -eq "" -or $yesno.tolower() -eq "y")
{
    &explorer.exe $pwd\$folder
}
}
else
{
    "ERROR: $pwd\$file not found"
}

Next thougts are to convert it into a standard documentation directly or crop the slideshow of.

But these are plans for the future,
as well as adding some more comments to the code ;-)

Update

As there are several errors with the linefeeds while copying the source code, here you can download it as a .zip-File

psr.zip