grokgarble.com

Database, Software, and System Engineering

Automated PICS-Label Generation Using PowerShell for IIS 7

Need the correct PICS-Label HTTP response headers for 0 ratings added to your Default Web Site in IIS 7 using PowerShell?  This post has you covered.

This is for that age old “Content Advisor” requirement in IE feature for me.  It is a feature of some browsers, primarily Internet Explorer, that enable end users to safeguard children from places on the net with a parental password.  There are ratings that can be embedded within, so read the standards if you’re wanting something specific for your site.  Keep in mind that this is header usage is  deprecated.  If you’re interested in the new method, you can check POWDER out here.

Here’s a script answer using the WebAdministration PowerShell module and its cmdlets that takes your URL as a parameter:

Usage: .\Set-PICSLabel.ps1 -URL http://jeffmurr.com

param (
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string] $URL
)
Import-Module WebAdministration
$PICSLabel = Get-WebConfiguration system.webServer/httpProtocol/customHeaders/* 'IIS:\sites\Default Web Site' | where {$_.name -eq "pics-label"}
if($PICSLabel) {write-host "PICS-Label already exists. No updates made."}
else {
write-host "PICS-Label does not exists. Adding PICS-Label..."
Add-WebConfiguration -Filter /system.webServer/httpProtocol/customHeaders -PSPath "IIS:\sites\Default Web Site" -Value @{name='PICS-Label';value="(pics-1.1 `"http://www.icra.org/pics/vocabularyv03/`" l gen true for `"$URL `" r (c 0 l 0 n 0 oa 0 ob 0 oc 0 od 0 oe 0 of 0 og 0 oh 0 s 0 v 0))"}
write-host "PICS-Label created."
}

The script above imports the WebAdministration module and uses that module’s Get-WebConfiguration cmdlet to create and array object of all of the customer headers where the name is “pics-label” called $PICSLabel.  This is only a test to see if its already exists and is recursed through all child objects under the default site object.  If the object is not NULL it returns “true” for the if statement and the Add-WebConfiguration cmdlet is used to add the correct values to the default web.config at the site’s root.

A formatted header looks like this:

(pics-1.1 "http://www.icra.org/pics/vocabularyv03/" l gen true for "http://jeffmurr.com " r (c 0 l 0 n 0 oa 0 ob 0 oc 0 od 0 oe 0 of 0 og 0 oh 0 s 0 v 0))

Note:  Spacing and format are critical or end user errors will result.

It is not required that the definition of the pics-label header be at the site level; however, not doing so can be confusing of the URL content of the header to the parsing engine and browser.  For that reason, its just simpler and easier to always define the header at the site’s root unless specific child applications have different ratings than that of the site.

The response header name “pics-label” is what is parsed for content ratings.  PICS stands for “Platform for Internet Content Selection”.  Its use in standards are defined by World Wide Web Consortium (W3) here.  In short, it is a voluntarily rating system that is used to protect children from inappropriate content on the web.  Parents can configure it to allow sites based on the voluntary ratings made by the site’s owner or block based on those ratings.  Most use it to require a password to visit regardless of the voluntary ratings provided in the header.

Internet explorer uses this in the its Content Advisor feature.  It is enabled and configured when accessed under the internet options section of IE under the content tab.

InternetExplorer-ContentAdvisor

For Internet Explorer’s Content Advisor feature, parents can set up ratings that they want to allow and trust site administrators to be honest about the material on their site.  More often than not, the password option is used for the URL content to all/not allow a site.  The password can be required on each visit or the parent can “white list” a site after providing the password using the URL content of the pics-label header.

Even though the ICRA has discontinued its ratings dictionary, many users still use it as an easy parenting tool to protect children from wandering into unknown areas of the net.  There are other rating dictionaries other than the ICRA, but it still seems to be the most widely used and why it was my choice in the script.

,

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>