Installing VisualEditor for MediaWiki on IIS

This post is part of a series of posts about MediaWiki on Windows :

  1. Installing MediaWiki on Windows Server 2012 R2 Core
  2. Installing VisualEditor for MediaWiki on IIS
  3. Enabling Media / File Uploads For MediaWiki on Windows Server
  • Download and Install Git
    • Get the exe install from http://git-scm.com/download/win
    • Run install from powershell commandline
      • Git.exe /verysilent /LOG="C:\temp\gitinstall.log"
      • Wait a few minutes, then check the log to ensure successful install
      • Add Git folder to Path Environment Variable
        • SETX /M PATH "PATH%;C:\Program Files\Git\bin"
  • VisualEditor extension requires Parsoid (a component which converts wiki-text to html)
    • Download and install Node.js x86 MSI from https://nodejs.org/download/release/latest/
      • msiexec /i node-x.msi /qn /l*v C:\Temp\nodeinstall.log
    • Download and Install Python
      • Download version 2.7.x from https://www.python.org/downloads/
      • msiexec /i python-2.7.x.msi /qn /l*v C:\temp\pythoninstall.log
      • SETX /M PYTHONHOME "C:\Python27"
      • SETX /M PATH "%PATH%;C:\Python27"
    • Set Node Python Version
      • npm config set python python2.7
    • Install Parsoid
    • Copy the localsettings.js.example file to localsettings.js and edit : you will need to replace this line with url of you mediawiki
      • uri: 'http://localhost/w/api.php',
    • Start parsoid
      • node bin\server.js
      • This will start parsoid in a local session, when the machine is restarted – it won’t run again. We will sort this out at the end…
  • To ensure you get a version of VisualEditor that is compatible with the installed mediawiki visit the following site and download the appropriate version :
  • To enable VisualEditor we need to edit the mediawiki LocalSettings.php and insert the following lines at the bottom

require_once "$IP/extensions/VisualEditor/VisualEditor.php";
// Enable by default for everybody
$wgDefaultUserOptions['visualeditor-enable'] = 1;
// Don't allow users to disable it
$wgHiddenPrefs[] = 'visualeditor-enable';
// OPTIONAL: Enable VisualEditor's experimental code features
#$wgDefaultUserOptions['visualeditor-enable-experimental'] = 1;

  • Go to your wiki in a browser and you should now have an extra ‘Edit Source’ option in the top right – this will take you to the old editor.

visualeditor_1

  • Click the edit button and you should see a loading bar and shortly after that the VisualEditor!

visualeditor_2

(UPDATE – i have noticed that the below will only work after a user logs in, I will edit this post with a fix once I have one…)

  • parsoid is running in a local session and we need to run it automatically.
    • I added a string registry key using regedit
    • HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
    • "C:\Program Files (x86)\nodejs\node.exe" C:\parsoid_install_dir\bin\server.js
  • Reboot the machine and check parsoid is still working by loading your wiki and trying to edit a page. If it doesnt work you the loading bar will pause about 3/4 of the way along

visualeditor_3

 

 

Advertisements

Installing MediaWiki on Windows Server 2012 R2 Core

Guide on how to install Media Wiki on Windows Server, using Web PI.

This post is part of a series of posts about MediaWiki on Windows :

  1. Installing MediaWiki on Windows Server 2012 R2 Core
  2. Installing VisualEditor for MediaWiki on IIS
  3. Enabling Media / File Uploads For MediaWiki on Windows Server
  • Install Server 2012 R2 Core on a machine or VM
  • Install IIS using powershell
    • Install-WindowsFeature -Name Web-Server
    • iis_install_serv_core
  • Install Microsoft Web Platform Installer (WebPI)
  • Install Media Wiki using webpicmd
    • Change the directory to : C:\Program Files\Microsoft\Web Platform Installer
    • Run the following command to install the MediaWiki application
      • .\webpicmd /Install /Application:MediaWiki
    • Web Pi will ask you several questions (config options, usernames and password etc…) at the end you should see :
    • media_wiki_core_install
  • Test the installation
  • At the next page i encountered a problem, the css didnt load
    • media_wiki_missing_css
  • I opened up the source and clicked the link which should load the css, this returned :
    • Exception encountered, of type "Less_Exception_Parser" [ec4dcf50] /mediawiki/mw-config/index.php?css=1 Less_Exception_Parser from line 447 of C:\inetpub\wwwroot\mediawiki\vendor\oyejorge\less.php\lib\Less\Parser.php: Less.php cache directory isn't writable: C:\Windows\TEMP Backtrace: #0 C:\inetpub\wwwroot\mediawiki\includes\resourceloader\ResourceLoader.php(1620): Less_Parser->SetCacheDir(string) ...
  • MediaWiki is trying to write to “C:\Window\TEMP” but the user context that PHP is running in (via IIS) doesn’t have permission.
    • !!! This is what I did to resolve the issue, its highly not recommended – it would be better to isolate the MediaWiki temp folder somewhere else !!!
      • Get an object representing the permissions of “C:\inetpub\wwwroot\mediawiki” folder
        • $acl_web = get-acl "C:\inetpub\wwwroot\mediawiki"
      • Get an array of just the access rules for *IUSR*
        • $perms = $acl_web.access|?{$_.identityreference -like "*IUSR*"}
      • Get an object representing just the access permissions for the TEMP folder
        • $acl_temp = (get-item "C:\Windows\TEMP").GetAccessControl("Access")
      • Add the access rules from the mediawiki folder to the temp folder acl
        • $perms | %{$acl_temp.AddAccessRule($_)}
      • Set the TEMP folder permissions to the newly created acl object
        • Set-Acl -path "C:\Windows\TEMP" -aclobject $acl_temp
    • I reloaded the wiki page in my browser and the CSS loaded properly
  • “Installing” MediaWiki
    • Choose language options and continue
    • The next page told me that i was ready to install mediawiki.
    • At the next page, i added the same MySQL options as during the WebPI command line install of MediaWiki
    • I left the database settings as default
    • Next add a title and create yourself a user account
    • This page allows you to change the reply address on the emails sent by mediawiki and also select some extensions. I choose just WikiEditor
    • Download your “LocalSettings.php”
    • Now we need to get this LocalSettings.php file to the server and store it in the mediawiki root folder.
      • I am using a virtual machine, so I opened the file and copied the text – then on the vm i opened notepad, pasted the text and saved the file as “C:\inetpub\wwwroot\mediawiki\LocalSettings.php”
  • I went back to the main page and this time it took a little longer to load – but loaded the Wiki correctly (it didn’t try to take me through install again, meaning it had picked up the settings)
  • To fully enable the WikiEditor extension, I had to add some more lines to the LocalSettings.php file more information : https://www.mediawiki.org/wiki/Extension:WikiEditor

Page loading initially was very slow at about 10s per page! This was happening because the database was being access using the hostname – localhost. This brings the ipv6 stack into play, which for some reason slows everything down.

To fix this, change the $wgDBserver variable in LocalSettings.php to 127.0.0.1 to force the use of ipv4

Disable Anti-Virus on W10 to Enabled Hyper-V

Today I wanted to enable Hyper-V on my home desktop but I encountered during the process…

0x80071A90

I thought it might be an issue with Windows Update, or an issue with missing source files, luckily it wasnt!

All I needed to do was disabled by Anti-Virus (Avast) in order to enabled Hyper-V.

Understanding the SCCM Database (using the Console)

I planned on publishing an article on how to use a log stored on the primary server to turn data you have queried in the SCCM console into an SQL query which can be used in Report Builder etc…

I drafted the beginning of this article in the middle of last year and didn’t get around to reviewing and finishing it until today. I had forgotten the location of the log required for this so googled it – and came across a blog post with all the information I planned to share – but with lots of screenshots and even instructions on using Report Builder.

So instead of re-inventing the wheel, I’ll link you to that excellent post instead!

http://www.scconfigmgr.com/2014/01/24/create-custom-reports-for-configmgr-2012-with-report-builder/

Regionalised SCCM Reports

The organisation i work for has 4 regions, these regions have changed over time as the business has moved and shifted. Meaning we don’t have the 4 region structure replicated in our Active Directory. This causes me alot of headaches when building reports. I am frequently asked for reports containing only data from specific regions – so I needed an easy way to ‘Regionalise’ my queries…

In the past, I’ve used several methods to include either the AD Site or the OU the machine is in. However – these methods have their drawbacks :

  • AD Site changes for laptops when they move around
  • The table in SCCM which has OU information for a machine contains multiple rows per machine, and our AD structure doesn’t represent the 4 regions – we have 5 top level OU’s

The table which has the OU information for a particular machine is stored in the following format, with a line for each node in the path :

  • COMPANY.COM/EUROPE
  • COMPANY.COM/EUROPE/COUNTRY
  • COMPANY.COM/EUROPE/COUNTRY/OFFICE
  • COMPANY.COM/EUROPE/COUNTRY/OFFICE/COMPUTERS

The easiest way I have found to tackle this problem is using a temporary table in the SQL query. We add the top level OU’s to this table so that we can join this table to the rest of the data in the query. If you ammend the below to OU names that match the ones in your SCCM DB you will be able to run it – however if you do, you will notice that we still have multiple rows per machine (which we dont want!)

-- Create Temporary Table to Store the OU's for each 'Region'
CREATE TABLE #Regions(
	RegionID int,
	RegionName NVARCHAR(50),
	RegionOU NVARCHAR(100)
)

-- Insert Data into Temporary Table
INSERT INTO 
	#Regions (RegionID, RegionName, RegionOU)
VALUES
	(0, 'AMX', 'COMPANY.COM/AMERICAS'),
	(1, 'AUS', 'COMPANY.COM/AUSTRALASIA'),
	(2, 'EAR', 'COMPANY.COM/EAST ASIA'),
	(3, 'EMEA', 'COMPANY.COM/EUROPE'),
	(4, 'EMEA', 'COMPANY.COM/AFRICA')

SELECT
	sys.Netbios_Name0 as [Hostname],
	ou.System_OU_Name0 as [OU],
	reg.RegionName

FROM
	v_R_System_Valid as sys
	INNER JOIN
	v_RA_System_SystemOUName as ou
		ON 
			sys.ResourceID = ou.ResourceID
	LEFT OUTER JOIN
	#Regions as reg 
		ON
			ou.System_OU_Name0 = reg.RegionOU

The beauty of doing it this way, is that; the only thing you need to do – to remove the unwanted rows is add a ‘WHERE’ clause to your SQL query.

The final query would look something like this :

-- Create Temporary Table to Store the OU's for each 'Region'
CREATE TABLE #Regions(
	RegionID int,
	RegionName NVARCHAR(50),
	RegionOU NVARCHAR(100)
)

-- Insert Data into Temporary Table
INSERT INTO 
	#Regions (RegionID, RegionName, RegionOU)
VALUES
	(0, 'AMX', 'COMPANY.COM/AMERICAS'),
	(1, 'AUS', 'COMPANY.COM/AUSTRALASIA'),
	(2, 'EAR', 'COMPANY.COM/EAST ASIA'),
	(3, 'EMEA', 'COMPANY.COM/EUROPE'),
	(4, 'EMEA', 'COMPANY.COM/AFRICA')

SELECT
	sys.Netbios_Name0 as [Hostname],
	ou.System_OU_Name0 as [OU],
	reg.RegionName

FROM
	v_R_System_Valid as sys
	INNER JOIN
	v_RA_System_SystemOUName as ou
		ON 
			sys.ResourceID = ou.ResourceID
	LEFT OUTER JOIN
	#Regions as reg 
		ON
			ou.System_OU_Name0 = reg.RegionOU
WHERE 
-- This clause removes unwanted rows
	reg.RegionOU IS NOT NULL

-- These lines are required to drop (remove) the temporary table now that we have finished with it. If you are working on a query and it doesnt fully execute, you may be left in a situation where the temporary table is not removed.
GO
DROP TABLE #Regions

Collecting Custom Properties / Fields Using the Registry and Hardware Inventory

I recently implemented a mechanism for collecting warranty end dates using a script which added the date to a registry key, then using hardware inventory to collect the key into SCCM SQL DB.

This is useful if there is information about a client machine which is not stored in WMI.

It worked great and proved a good method of collecting data, In this post i will cover the whole process in detail :

Step 1 – The Script

The first stage is creating a powershell, vbscript or bat file to grab the custom property you are looking for and write it to a registry key. I won’t go into the detail of doing that in this post. I am using a script which reads the setupact.log file in C:\Windows\Panther and returns whether the machine firmware is BIOS or EFI (UEFI) – then writes the info to a reg key. I couldn’t find a field in the registry or in WMI on Windows 7 which stores this information. (Hence the script and this post!)

Step 2 – The Deployment

The script needs to be deployed and run on every machines we want to collect information from. I find it easiest to create a source folder, place the powershell script in there and create a bat file ‘wrapper’ to call the powershell script and temporarily change the execution policy.

powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -WindowStyle Hidden -File "script.ps1" >> "%temp%\script.log"

For the detection method, use the following :

  • Setting Type: Registry
  • Hive: HKEY_LOCAL_MACHINE (or other if you are using different hive)
  • Key: SOFTWARE\CompanyName\YourKey (this is the key you have written your info too)
  • Value: NameOfKey
  • Data Type: String (or other if you are using different data type)
  • I used “This registry setting must satisfy the following rule to indicate the presence of this application”
  • Operator “Not equal to”
  • Value: <blank>

Sometimes my script would fail to gather the info required but would create the key with null value, i didnt want my detection rule to be satisified by this. (I know i was lazy and should have added more error checking the script! But this had the same outcome….)

Step 3 – The Mof File

Great! We have the info in the registry, but now we want to add it to the SCCM DB – for ease of querying and reporting etc…

This method was inspired by this brilliant post – https://sccmguru.wordpress.com/2014/04/24/hp-and-lenovo-warranty-information-in-configuration-manager-2012-r2/

I suggest using the methods described in the above post to create your MOF file and import the changes into ConfigMgr.

Step 4 – The Result

Once you have deployed the hardware inventory custom settings, the deployment has run on some machines and hardware inv has run you should have some results! If not, something is wrong, retrace your steps and check for mistakes…

Windows Driver Overview

I have spent a lot of time working on a solution to update drivers on existing machines lately. Once I started working on this, I realised that I knew less about drivers than i thought i did. I thought i would write this article with a summary of technical details about windows drivers.

Who Produces Drivers, Microsoft?
Drivers are produced by Independent Hardware Vendors (IHV) and then submitted to Microsoft to gain Windows Hardware Certification (to be signed). System manufacturers such as Dell and HP (OEMs) do not produce drivers, but publish the ones for their systems produced by IHV’s. Sometimes OEM’s will work with IHV’s to improve drivers or customize them to interact with other components.

Types of Driver

  • InBoxDrivers which come with the Operating System are called “InBox Drivers” – with each version of Windows, Microsoft adds more and more of these drivers.
  • Windows UpdateWhen a driver is going through the Windows Hardware Certification process, the IHV has the option to add the driver to Windows Update. This means that you can search for a PNP ID (more about these later) here and find a nice signed driver to install on your system.
  • Exe PackageThese are drivers which have been re-packaged by an IHV or OEM into a convenient format to download and double click to install. These are great for normal users, but for system manager hoping for automation they are a nightmare. On occasion the original clean driver files can be extracted from the exe, but they may require user input to install correctly. Which is a problem when you want a silent installation for deployment.
  • FakeThere are numerous websites pretending to offer a magic tool to scan and update all drivers on your system – unless this tool is made by your system builder (Dell, HP, Lenovo, MSI, ASUS etc…) DO NOT USE! Read this article on How-To Geek for more information.

WTF is PNP?
PnP stands for Plug and Play and is a standardization system that makes the detection of hardware in a system easier. More Information
Vendors should incorporate unique ID’s into hardware components. These consist of several sections of ID. (Hardware ID, Vendor ID, SubSystem ID).

e.g. PCI\VEN_1000&DEV_0001&SUBSYS_00000000&REV_02

Woah – Slow Down, PNP ID?
To see the hardware id of a device in a system – do the following…

  • Open Device Manager
  • Right Click on a Device from the Tree and Select Properties
  • Change to the Details Tab
  • Select Hardware ID for the Property

Hardware IDs

How Does Windows Match Drivers and Hardware IDs?
The simple answer to this, is that each driver has a list of Hardware ID’s that it is compatible with integrated into the files of the driver (the *.inf files).

Extract from an *.inf file.  For the geeks out there - Intel's Vendor ID = 8086 :-)
Extract from an *.inf file. For the geeks out there – Intel’s Vendor ID = 8086 🙂

I’m Confused!
You are not alone… The OS get’s confused as well, what with all these ID’s, OEM’s, IHV’s etc… So how do Microsoft handle the issue? – Driver ranking!

Driver Ranking is used to choose an appropriate driver from a list, when there may be multiple drivers applicable. To do this, Windows sorts the drivers and gives them a rank.

What Criteria does it use?
I’m not going to go into detail about this, but the following is the basic guide for more information see – How Does Windows Rank Drivers

  • Signing
  • Plug and Play ID Match
  • Driver Date
  • Driver Version

Before any drivers are loaded by the operating system, they must be ‘staged’ into the DriverStore. The driverstore is a secure location of drivers, which the operating systems dip’s into to find drivers for devices which require them. DPInst.exe can be used to ‘stage’ the drivers – once staged they will be ranked and if they are the lowest rank will be loaded by the OS.

DPInst.exe

I have a found a utility that makes automated driver updates on machines via SCCM (or other methods) very easy. I will publish another article later in the week about it, with a Hot-To guide on updating drivers safely.