Category Archives: Microsoft Windows

CSS, Javascript, Images cause 500 errors after IIS Website upgrade

Symptoms

A website has been copied from a server running IIS 6 (Windows Server 2008) to a server running IIS 10 (Windows Server 2019). Pages do not render correctly, and further investigation shows that pictures, css files, and javascript are all failing with 500 (Internal Server Error) responses. This is shown here in the F12 view in Chrome.

 2020-02-13_11-18-38

Trying to access one of these static files directly also fails and just shows the message “The page cannot be displayed because an internal server error has occurred.

2020-02-13_11-17-35

Cause

In my case, the site was referencing the FontAwesome package which uses the WOFF file type. In the older IIS this MIME type was not registered so required a manual entry in the configuration. In the newer IIS this is handled natively and the manual configuration is now causing a problem rather than remediating one.

Solution

Check the web.config file for a reference to “woff” for example

<mimeMap fileExtension=”.woff” mimetype=”application/font-woff” />

and comment out or remove this line.

2020-02-13_11-20-07

Refresh the page in your browser and it should now load correctly.

Get the Windows Install Date of a remote computer with PowerShell

A quick script that came up in response to a situation where I wanted to know the date a workstation on the network was last built without visiting the machine or interrupting the currently logged on user. PowerShell to the rescue!

The WMI property “InstallDate” comes into play here.

(Get-WmiObject Win32_OperatingSystem).InstallDate

Returns a date: “20180717202039.000000+060” for my workstation. The Get-WmiObject cmdlet can again be leveraged to make this into a more usable PowerShell DateTime object:

(Get-WmiObject Win32_OperatingSystem).ConvertToDateTime( (Get-WmiObject Win32_OperatingSystem).InstallDate )

Which returns 17 July 2018 20:20:39.

Get-WmiObject can also be used on a remote computer, this example would return the date that the computer called WS12000 was built.

(Get-WmiObject win32_OperatingSystem –ComputerName “WS12000”).InstallDate

I’ve taken this work and expanded it into a PowerShell function (available on GitHub). This function “Get-BuildDate” takes one or more computer names and returns a table of build dates and, because it’s handy, the number of days that have passed since that date.

Some example usage would be:

Return the installation date of workstation 40200:

Get-BuildDate  -ComputerNames "WS40200"

Computer BuildDate           DaysSinceLastBuild
-------- ---------           ------------------
WS40200  17/07/2018 20:20:39                 55

Return the installation date of workstations WS40200 and WS46000:

Get-BuildDate ("WS40200","WS46000")

or alternatively using pipeline input:

("WS40200","WS46000") | Get-BuildDate

Finally, return a table of the last build dates for the sequentially numbered computers called WS12300, WS12301, WS12302…. right through to WS12399:

$Computers=((12300..12399) | ForEach-Object{ "WS$_"}) | Get-BuildDate

The script (and any future refinements) is available here: https://github.com/isjwuk/powershell-general/blob/master/Get-BuildDate.ps1

PowerShell Snippet – Find Windows 2008 VMs before EOL

Support for Windows Server 2008 and 2008 R2 ends in January 2020– just two years from the date of this post. Four years ago I put up a script to find XP and 2003 VMs, and I’ve modified this to search a vSphere environment for powered on VMs running Server 2008 as a Guest OS:

Get-VM |
 Where {$_.PowerState -eq "PoweredOn" -and
 ($_.Guest -like "*Server 2008*")} |
 get-VMGuest |
 select VmName, OSFullName

VmName    OSFullName
------    ----------
MyVM1     Microsoft Windows Server 2008 R2 (64-bit)
MyVM2     Microsoft Windows Server 2008 R2 (64-bit)
MyVM3     Microsoft Windows Server 2008 (64-bit)
MyVM4     Microsoft Windows Server 2008 R2 (64-bit)

Microsoft.Jet.OLEDB.4.0 provider is not registered on the local machine

I’ve come across this error a couple of times in the past few weeks when migrating old ASP.NET websites to new web servers so I’m popping it into the blog as an aide-memoire for myself and in case it’s useful for others.

The error message below (“Server Error in … Application”, “The Microsoft.Jet.OLEDB.4.0 provider is not registered on the local machine) pops up when trying to open a page which uses the database (in this case a Microsoft Access DB).

2017-06-16

The fix is to enable 32-bit applications for the relevant Application Pool using Internet Information Services Manager.  The Jet drivers are not 64-bit, and by default IIS8 (Server 2012R2) has 32-bit apps disabled.

  1. Open IIS Manager
  2. Navigate to the Application Pools Node underneath the web server.
  3. Select the App Pool in question. If in doubt look at the “Applications” column, if only one has any applications in it then that’s the one you want 🙂
  4. On the Actions menu on the right-hand side click on “Advanced Settings”
  5. In the “Advanced Settings” dialog set the value of “Enable 32-Bit Applications” to True and click OK.

2017-06-16 (1)

OneDrive, Placeholders, and shared PCs.

OneDrive now with Files On Demand

At their annual Build conference, Microsoft announced that OneDrive was getting a new feature called “Files On Demand”- basically a replacement for the placeholders feature that was present in Windows 8.1’s OneDrive client. The official Office blog goes into more detail about the new features, and there’s a detailed writeup by Paul Thurrott which also includes the history of OneDrive placeholders, but I’d like to discuss the advantages for the education vertical- in particular Student PC labs.

Microsoft kindly offer OneDrive to University students for basically nothing, so it sounds like an ideal replacement for traditional on-premises network file-shares. Rather than the IT department struggling to provide 50 or 100GB of space per student from their budget, they could just point students at the 1 TB of disk Microsoft is providing for free.

Sync Good

A sink. Not a sync

Not this kind of sync


With a single regular user and enough local hard disk space a sync client without placeholders is fine. All the users files are synced to the local disk and available instantly whenever they are required. The selective sync in the current Windows 10 client helps on devices with smaller disks, but is still only really beneficial on a PC with a single regular user.

Sync Bad

On the students personal devices this works great- we’re back at this 1 user:1 device ratio. However in a student PC lab environment there are potentially hundreds of desktops and each of tens of thousands of users could log into any one at any time. We have a x,000:1 user:device ratio. Students don’t want to login to a machine at the start of a class and then wait whilst half a terabyte of data they don’t need syncs before document they need appears. Additionally IT don’t want to have to tidy up all this synced data after every user logs off.

Student Computer Labs

It’s technically possible (although can be a little fiddly depending on your infrastructure) to map your OneDrive to a drive letter using WebDav and then access it as you would a traditional “Home” drive, but this is unsupported by Microsoft. There are third party solutions that will map the drive, basically providing a front end and a support contract around this, but they’re often costly and may require infrastructure changes.

Placeholders FTW

Placeholders (or “Files On Demand”) is the ideal solution here. The student now sits down at the shared lab machine and all their files are listed. They then open the file of their choice and there’s an invisible, seamless, download in the background. When they save the file it’s synced back to the cloud. The user is happy as they no longer has to wait for all their files to sync before they can work and can take advantage of the large capacity (and sharing facilities too). IT are happy because they don’t have to fund (and support, maintain) as much storage.

I know many IT Professionals working in Higher Education will be looking forward to this release in the autumn.