Thursday 31 December 2015

Debunking the cult of Apple

Of course, I don't believe in any kind of personality cult. This article debunks the cult of Steve Jobs to quite an extent by suggesting he was just another capitalist like Gates. I don't know anyone who idolises Gates that much. Apple have made some great hardware, but the prices they charge help to create the kind of elitism they aspire to, by pushing the purchase out of reach for a lot of people. That is one reason why the Ipad is so popular, because the cost has come down to something an average person can afford, but then it throws into hard focus why people are expected to pay so much more for a Macbook, Imac or Mac Pro.

Alex Gibney also made a documentary called "The Man in the Machine". The second article linked to refers to that documentary, and also a book which has questioned whether Apple will turn out to be too dependent on its visionary leader and floundering since he has gone. I think that is a very real likelihood because it has happened in so many other corporates; look at Microsoft's history under Steve Ballmer and all of their many new product fiascos. Apple went through that too, starting with Jobs' original tenure in charge of the Mac product development and launch, which soon demanded change he was unwilling to provide as early sales figures flopped, and which led to his ouster and departure. Apple did a lot of things right after he left, but it also made a lot of mistakes which led to his return 12 years later, and Jobs must have learned from the experience to have built the company up to where it was when he died. So there is plenty of scope for Apple to have a few challenges in the years ahead, and the size that the company is now makes it more likely to happen; a few bad product launches will hardly make a blip in a big company, but the US DOJ and EU will look at them a lot harder with antitrust considerations, and they are likely already in the legislators' sights.

The Mac4Newbies article is disappointing in that it dismisses the Apple scandals, the real ones like Jobs hounding Gizmodo over the lost iPhone prototype, suicide rates at Foxconn, the stock backdating scandal or the tax havens in Ireland. Over a four year period, from 1997 to 2001, after Jobs had returned as CEO, a number of backdated stock options were issued to Jobs and other senior Apple figures. The issue was that the options were not reported properly in Apple's books and led to charges of fraudulent behaviour against a couple of senior managers at the company. Both settled out of court and were subjected to various penalties by regulatory agencies. The tax rip-off is a much bigger issue not just for Apple but other companies worldwide which have engaged in similar practices to avoid paying tax in the countries in which they sell their products. In a nutshell this is how it works:
  • Manufacturer in the USA through its Chinese subsidiary makes a product in China for say $100
  • International Distribution in Ireland buys the product from Manufacturer's Chinese subsidiary for the $100 plus shipping costs.
  • International Distribution sells the product to New Zealand Retail subsidiary for $500.
  • New Zealand Retail ships the product to New Zealand and sells it for $600 to the customer.
We can see that a large amount of the profit was made in Ireland, not in the country where the sale was made. If a company in New Zealand is getting stuff manufactured, then the markup is generally going to occur in New Zealand and will be subject to our local laws and tax rates.  But if a company has enough volume of sales to open an office in Ireland then they can take advantage of the very low tax rates in that country in order to pay almost no tax. In fact there has more recently been allegations brought against Apple that Ireland improperly have levied almost no tax against them. The result has been that countries around the world are now looking at the amount of tax that is being avoided from these practices and it may well come to pass that Apple and other big corporates will find it much harder to engage in these practices in the future.

The doco is interesting because it managed to dig out a few people like one of the early Mac hardware developers, Bob Belleville, who haven't been in high profile roles since their time at Apple. Belleville got shown the door at the same time as Jobs, but unlike his erstwhile leader, little seems to be known of his work since then. Andy Hertfeld's Folklore website and the resulting book paint a great insight into some of the early developmental work at Apple, particularly around the time that the Mac was first developed in the mid 1980s.

Checking a mobile phone's IMEI status

All mobile phones have an IMEI number (International Mobile Equipment Identity). This number is part of an international system to uniquely identify each mobile phone. With the IMEI number phones can be identified and traced if they are stolen, or they can also be locked to a particular mobile operator's network. The IMEI number can be obtained from the phone in order to check its number.

The website IMEI.info claims to be able to check the status of the IMEI number of each phone and to advise whether a particular phone is simlocked. If you don't have another network sim card it may be the best way to check the simlock status for a phone.

I tried this with one of my old phones that I don't use any more. It is only 8 months old but I got a new phone two months ago and soon I will be buying my second Android, so I won't need that 8 month old as a backup. Along the way I discovered Vodafone now sells all of their phones locked out of the box. But if you can wait 9 months after you bought the phone, they don't charge you anything to unlock it.


Saturday 26 December 2015

Resolving long path errors deleting files in Windows

One of the most detested situations in just about any version of Windows is to receive the message that the path to a file or folder is too long. There are a number of variations of this message but one that is commonly seen when trying to delete files is "The source filenames are larger than is supported by the filesystem" which is an absolute load of BS and a total pack of lies. This is because the filesystem allowed these files to be created in the first place.

What is happening is that the filesystem since the advent of the Win32 API on Windows NT (the predecessor of Windows 10 going back to the very first version ever produced, NT 3.1 of 1993) has, in fact, supported paths up to 32768 characters in length, but because Windows Explorer was designed for a previous version of Windows (16-bit i.e. Windows 95 and its predecessors) that only supported 259 character paths (drive letter, colon and backslash plus 256 characters), it still enforces that limit. This creates a huge problem when trying to delete old files or paths (for example cleaning up the contents of a backup disk and removing old backups to make way for new ones).

The fact MS has never bothered to fix Explorer which means a huge inconvenience for many users means everyone has to find a way of bypassing Explorer to fix these problems. There are a number of different solutions which I have seen at different times.
  • A special script calling Robocopy to reach the bottom of a directory path and move each directory up one level at a time until it can be deleted. I used this one but can't recall where I got it from.
  • A useful looking program called Long Path Fixer appears to be able to address this problem. I have not tried testing this software.
  • The simplest option which I am now using is the file manager from 7-Zip. Since this excellent piece of software is already on all my computers, this has been the easiest to test and implement and has proved to do exactly what is needed provided it is used in the right way.
Specifically you start up the 7-Zip File Manager, then use that to browse to the folder you want to delete, select the folder and then using the keyboard press the Del key to recycle, or Shift+Del to delete outright. Note that pressing the Delete button or right clicking and choosing Delete actually work differently and are not as reliable as they will still produce the detestable error message. You have to use the keyboard commands to guarantee hassle-free results.

So after all of the huge hassles and inconvenience that MS has inflicted over the years due to a huge amount of uselessness from its programmers then being able to solve this problem is a great step forward.

Monday 21 December 2015

How to stop the popup notifications in Windows 10

If you have computers that are used continuously or exclusively for presentation then you may want to look at ways of stopping popup or toast notifications in Windows 10. After all one of the most annoying notifications is the one for new updates which is modal and therefore unable to be ignored, then it opens another window which can be very annoying.

(Presentation computers should also have the Updates settings changed so the updates don't just automatically install when MS feels like it and disrupt your use of the computer)

Using the Local Group Policy Editor you can accomplish the removal of notifications by permanently enabling Quiet Hours mode and preventing it from being turned off. This is only a per user setting rather than for the whole computer so you'll want to ensure you have a limited number of users on such a computer and you will need to make the changes for each one individually. You must be using an edition of Windows that allows local group policy editing, such as Pro, Enterprise or Education.


Here you can see where to find the settings in the local group policy and what they can be set to. The minimum I recommend are:
  • Set the time quiet hours begins - I enabled this and set it to 0 minutes after midnight
  • Set the time quiet hours ends - I enabled this and set it to 1439 minutes (23 hours 59 minutes) after midnight.
  • Turn off quiet hours - set to disabled. Doing this turns on quiet hours and it cannot be turned off with the icon in the system notification area. (The icon gives you the on/off settings in its context menu but clicking on them does nothing; the system will remain quiet)
Any settings you change will take effect more or less immediately.


Tuesday 8 December 2015

Using Windows 7 Photo Viewer in Windows 10

There is a great reason for this :) I like the Windows Photo Viewer which offers one-handed zooming with the mouse wheel and you just use the arrow keys on the keyboard to move to the next image. On the new Windows 10 photo viewer you have to press Ctrl to zoom with the mouse wheel and have to zoom right back before you can click the arrows at each side to go to the next or previous image.
To get the Windows 7 photo viewer back in Windows 10 is described in this article here
To summarise all you need to do is
  • Add these entries to the registry - copy them into a text file then rename it to a .reg file. Then double click the file to import it to the registry.
  • Right click on a photo and choose the app to open it as "Windows Photo Viewer".
This is quite a safe procedure because the registry entries contained below refer to the existing photoviewer.dll which is part of Windows and already installed in your system. It is not adding anything new to your system.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Applications\photoviewer.dll]

[HKEY_CLASSES_ROOT\Applications\photoviewer.dll\shell]

[HKEY_CLASSES_ROOT\Applications\photoviewer.dll\shell\open]
"MuiVerb"="@photoviewer.dll,-3043"

[HKEY_CLASSES_ROOT\Applications\photoviewer.dll\shell\open\command]
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,72,00,75,00,\
6e,00,64,00,6c,00,6c,00,33,00,32,00,2e,00,65,00,78,00,65,00,20,00,22,00,25,\
00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,46,00,69,00,6c,00,65,00,73,00,\
25,00,5c,00,57,00,69,00,6e,00,64,00,6f,00,77,00,73,00,20,00,50,00,68,00,6f,\
00,74,00,6f,00,20,00,56,00,69,00,65,00,77,00,65,00,72,00,5c,00,50,00,68,00,\
6f,00,74,00,6f,00,56,00,69,00,65,00,77,00,65,00,72,00,2e,00,64,00,6c,00,6c,\
00,22,00,2c,00,20,00,49,00,6d,00,61,00,67,00,65,00,56,00,69,00,65,00,77,00,\
5f,00,46,00,75,00,6c,00,6c,00,73,00,63,00,72,00,65,00,65,00,6e,00,20,00,25,\
00,31,00,00,00

[HKEY_CLASSES_ROOT\Applications\photoviewer.dll\shell\open\DropTarget]
"Clsid"="{FFE2A43C-56B9-4bf5-9A79-CC6D4285608A}"

[HKEY_CLASSES_ROOT\Applications\photoviewer.dll\shell\print]

[HKEY_CLASSES_ROOT\Applications\photoviewer.dll\shell\print\command]
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,72,00,75,00,\
6e,00,64,00,6c,00,6c,00,33,00,32,00,2e,00,65,00,78,00,65,00,20,00,22,00,25,\
00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,46,00,69,00,6c,00,65,00,73,00,\
25,00,5c,00,57,00,69,00,6e,00,64,00,6f,00,77,00,73,00,20,00,50,00,68,00,6f,\
00,74,00,6f,00,20,00,56,00,69,00,65,00,77,00,65,00,72,00,5c,00,50,00,68,00,\
6f,00,74,00,6f,00,56,00,69,00,65,00,77,00,65,00,72,00,2e,00,64,00,6c,00,6c,\
00,22,00,2c,00,20,00,49,00,6d,00,61,00,67,00,65,00,56,00,69,00,65,00,77,00,\
5f,00,46,00,75,00,6c,00,6c,00,73,00,63,00,72,00,65,00,65,00,6e,00,20,00,25,\
00,31,00,00,00

[HKEY_CLASSES_ROOT\Applications\photoviewer.dll\shell\print\DropTarget]
"Clsid"="{60fd46de-f830-4894-a628-6fa81bc0190d}"

Please note this has been updated to fix the problem with the above registry entries. There turned out to be a problem with copying them from the reg file to paste into this post, which has something to do with the way the registry file is formatted.

Saturday 21 November 2015

Try using Queens English, Google!

Lovely error message on Google Drive this morning


Which doesn't make sense until you realise this operation must have taken place on another computer or in another browser. It wouldn't take much effort for the phraseology to be less terse and more user friendly, frankly.

Wednesday 11 November 2015

This is how Apple rips off governments on tax

http://www.nzherald.co.nz/business/news/article.cfm?c_id=3&objectid=11541189

Tim Cook talks Apple cult BS

Sorry, a non proprietary computer platform that we can run anything on (except Apple's cult OS) and that we can fix and repair ourselves isn't disappearing anytime soon. I guess these guys are so wrapped up in their cult that they believe anything.

There are still plenty of people out there who have not sold their souls to the cult of Apple and have got a clue that they do not need to spend their days playing with hand held devices that are chained to Apple's servers on the far side of the world. Devices that are essentially throwaway if they break out of warranty. Too difficult and expensive to repair.




Sunday 8 November 2015

New Uploadr sucks

Well Flickr have released a new Uploadr tool. They had one some years back that was discontinued and now they have brought out this one that, to be frank, does look a lot like the Google Photos uploader tool.

However anyone who is expecting it to be like the previous Uploadr (which was a third party tool) will be very disappointed. While it can store photos automatically into albums, they are all set to private by default and there is no way to change this behaviour as there are very limited configuration options. The software is really set up as a backup tool, not an upload tool for publishing photos.

The biggest problems I am seeing with this software is that it is very slow and often stalls during the process (I would guess it is unable to deal with upload timeouts, which seem to be a common feature of the Yahoo platform). This means you are bound to have to close and restart the software if you are uploading a lot of photos at a time. The initialisation phase of the software seems to involve a lot of disk churning and take a very long time to complete.

The only really useful feature on it is the built in deduplicator. This is the one thing that makes it almost worthwhile to have. But it could be so much better and have the ability to publish albums as well, considering that they appear like normal albums in my photo collection; they just aren't public.

Changing Windows 10 update settings

If you have Windows 10 Pro, Education or Enterprise, you may yearn for the original (since Windows XP) granularity of Windows Update settings. The GUI offered in 10's regular Settings screen only gives a limited range of options, and unlike many of the areas of the settings screen, the Control Panel version of the Updates app has been removed. 

On these editions of Windows, the Local Group Policy editor provides access to group policy settings for the local computer that are essentially unchanged from XP days. Domain administrators can use the group policy tools to push these settings out to all the computers in their site, but the local policy can be used on any computer, not just one that is joined in a domain.

Open the Local Group Policy editor by running gpedit.msc and then find the updates settings in the following location:
  • Expand Computer Configuration
  • Expand Administrative Templates
  • Expand Windows Components
  • Select Windows Update
What you can see in there is a mixture of settings that apply to different editions of Windows. The ones I can see go back as far as Windows XP Service Pack 1, but there are also ones that go to Windows Vista, Windows 7, Windows 8 and Windows 10. Also, some of the settings are only applicable when you have your own Windows Server Update Services installation inside a site. The server that is running WSUS can manage all of the updates across a site and make sure bandwidth is being used efficiently. WSUS is a great tool if your internet bandwidth is slow or expensive but it doesn't justify itself at sites with a flat rate connection or where a small number of computers don't really need the management overhead.

So to the settings that are useful:
  • Enabling Windows Update Power Management to automatically wake up the system to install scheduled updates - appears only to apply to 7/Vista/2008. Apparently being in hibernation is not a guarantee the system is not going to update itself without you knowing. I always turn my PCs off at the wall as soon as they have gone into hibernation so they will never wake themselves up which makes this setting irrelevant.
  • Configure automatic updates - is the main configuration option we are all familiar with from earlier editions of Windows. Enable this policy then choose whether you want the system to automatically install the updates, download and notify you, or let you decide when to download and when to install. 
  • Defer Upgrade - this Windows 10 setting is one of the few available in the settings GUI. I advise enabling it.
  • No auto-restart with logged on users for scheduled automaric updates installations - this makes sure the system will not force an automatic restart if you have the Configure Automatic Updates setting set to auto-install updates. Enabling this is recommended.
  •  There are some other similar settings which I have not covered as I have set my "Configure Automatic Updates" policy to ask me before it installs anything, and if you choose this one at least you are spared the default behaviour where you just get kicked off your own computer and everything is force closed whether you had unsaved work or not.

Sunday 1 November 2015

$1 Iphone scam

I always thought this was going to be a scam, well it has been shown up to be one as expected because of the false claim that Apple would sell their phones for $1.

Saturday 24 October 2015

Changing text font sizes on Blogger's "Simple" template

As you may have noticed most of my blogs use the "Simple" template (this one currently uses "Picture Window"). With various upgrades to Google's blogger posting system over the years we can set some of the text sizes without having to directly hack the template's HTML code.

One of the changes I have been making recently to some of my blogs is to change the body text in a post to a different font and size. Unfortunately while it is possible to set these indirectly there is no direct way of setting the size.

The font of the post body is affected by the setting in the Template Designer called Page Text which sets a font for the whole of the page, and a base font size. This size does not directly set the size of the text in the post body.

Once you have set the above setting then customise the template HTML to adjust the body text size. The full section you are looking for is as below:

/* Posts
----------------------------------------------- */
h2.date-header {
  font: $(date.header.font);
}
.date-header span {
  background-color: $(date.header.background.color);
  color: $(date.header.color);
  padding: $(date.header.padding);
  letter-spacing: $(date.header.letterspacing);
  margin: $(date.header.margin);
}
.main-inner {
  padding-top: $(main.padding.top);
  padding-bottom: $(main.padding.bottom);
}
.main-inner .column-center-inner {
  padding: 0 $(main.padding);
}
.main-inner .column-center-inner .section {
  margin: 0 $(main.section.margin);
}
.post {
  margin: 0 0 $(post.margin.bottom) 0;
}
h3.post-title, .comments h4 {
  font: $(post.title.font);
  margin: .75em 0 0;
}
.post-body {
  font-size: 120%;
  line-height: 1.4;
  position: relative;

}
I have bolded the part that is important. This is line 389 of the template at the time of writing. In the line font-size: 120%  change that number to whatever suits you. This will step up or down the body text size in the post.



Wednesday 7 October 2015

Using Android

Well after a few days of setting things up and testing (with a prepay account) I have finally switched my phone to my regular on account plan. I have a couple of coloured backs on order for it too, although they are difficult to get in NZ; fortunately it doesn't cost too much to have Amazon post one across to NZ. 

The built in email app works fine with Exchange, and the Gmail app works fine with Gmail, and the Outlook app from Microsoft works fine with Live accounts. The advantage of using the Outlook app instead of setting up my Live account from my Windows phone as IMAP, is that it immediately brought down my address book from Windows Phone, which includes all the phone numbers I previously had stored. However it doesn't look like the app can access IMAP accounts which means I will have to use the Gmail app; fortunately it isn't as messy to use multiple email apps as it is on a PC because their notifications are all integrated into the notification centre that comes up on the lock screen and when you pull down from the top. 

Live tiles are all the rage in Windows Phone of course, but they are limited, and the notification centre in Android is probably just as good overall, although I will miss having the visible calendar that showed everything by default, and will have to make sure I keep up with what is in my calendars by some means. I am guessing the Outlook app should be able to do calendar notifications.

The biggest issue for any Android user is apps that will only work in the phone's internal memory, which is most of them. You can disable many of the built-in apps that you don't use and free up some space, or a small number of apps can be moved to the SD card. The problem is that an old trick of using the Android Device Bridge application running on a PC to force move apps to the SD card is not possible in the latest versions of Android (this is running 5.1, which it was easily updated to soon after I started using it). So Google is not making it easy for people with lower priced phones to make the best use of the onboard memory as a lot of apps will not be installable. For me I am just OK with using the Chrome browser to view Facebook and Trademe and some other sites.

Saturday 26 September 2015

My first Android phone


So I bought a Motorola Moto E on special (end of line) from the Warehouse. This is the 2014 model, seen above with the Lumia 520 on the left and the Lumia 635 in the middle. The screen just happens to be the same size as the Lumia 635 despite the latter's larger package. This morning I let the phone update itself to Android 5.1. It is interesting for being a dual SIM phone and has a sticker on the outside of the box mentioning 2 Degrees, but is in fact a retail model so is not locked and didn't come with a SIM.

Buying an Android phone is about getting access to a lot more apps that won't be available on Windows phone for a long time because of the dismally small market share that Windows Mobile has. (That is the new name for the platform since Windows 10 by the way) Even though Windows Mobile 10 is going to let Android apps run on it, I still think there is merit for me to own an Android phone.

I will have a look at making it my main phone, but that depends on whether it can work with the work email which is on a Microsoft Exchange server. The main reason as of now is to be able to load my e-Bible onto it, as that is a Adobe Digital Editions DRM protected EPub, and I couldn't find a suitable app for the Lumia.

Well eventually I did get my NIV Study Edition loaded onto it, after looking at a few different options. The main issue has been finding an app that will work with Adobe Digital Editions specifically. It turns out the only suitable one is Aldiko Book Reader. While ebooks.com from whom I purchased the e-book have their own reader app, I have found both on Windows and now Android that this app is very poorly designed with unhelpful error messages and being unable to either download the e-book or import it from the SD card. More than likely the ebooks app is not authorised to work with Adobe DRM.

Out of several reader apps, Vitalsource Bookshelf is the most disappointing. I understand that the objective of it is to produce an exact replication of a page layout and that therefore it is unable to reflow text to suit the reading device. This limitation prevents it being used on small screen devices such as phones. At least with Kindle or Aldiko the text can reflow to work on a screen. So the idea I could have some of my textbooks with me anywhere on the phone just ain't gonna happen unfortunately. Maybe I start thinking about an Android tablet sometime,

Monday 21 September 2015

How to print to a colour PCL printer from a Mac

If you know the Mac platform well, then you know that PostScript is the preferred printing system for OSX and all its precedessors way back to the very early Macs. This comes about because Apple virtually invented PostScript printing and desktop publishing about thirty years ago partnering with Aldus, the inventors of PostScript (which later became Adobe). Whereas on Windows, PCL is the de facto print standard, although PostScript is also supported.

The problem is, there are cases where you will want to print to a printer that only supports PCL, and PCL drivers officially provided for the platform may be few and far between. Apple supplies a "Generic PCL" driver for OSX, but colour printing is not supported with this driver. We have a school customer with a pile of Ricoh photocopiers that don't have any PostScript capability and with which the Ricoh PostScript drivers wouldn't work. So, we needed a Ricoh PCL driver for the Mac, and officially, there are none.

But thanks to the Linux community there are good third-party drivers available, through Foomatic.

Go to this site (OpenPrinting) and there is information about OSX HP drivers. You could install these drivers if you have an HP printer. In this case we could have used these drivers for compatibility and they would probably be OK to a certain extent. However I did find another place where the Ricoh PXL drivers (PCL XL) can be downloaded.

The OpenPrinting page provides links to download the Foomatic RIP and GhostScript software, which you will need anyway, so go ahead and download those from the page.

Then go to OpenPrint's Ricoh downloads folder and find the driver for your Ricoh printer. In this case the MPC 4502 PXL.ppd file was the one needed.

Install Foomatic and GhostScript onto the Mac in that order, and then you need to make a small fix in the PPD file. Open it with a text editor, find the line that reads

*cupsFilter: "application/vnd.cups-pdf 0 foomatic-rip"

and change this to

*%cupsFilter: "application/vnd.cups-pdf 0 foomatic-rip"

then save the file.

You can then install a printer in the usual way, choosing the option to install a driver and opening the PPD file.

Friday 11 September 2015

Mozilla Thunderbird

So I am trialling out Tbird again. For some reason I disliked it for quite a long time even though I used it a lot, years ago. I suspect the interface was kind of clunky, but of course there are all these styles available now. Really easy to set up with Google and Hotmail accounts, and with the calendar extension which is integrated, you just need a Gdata provider extension to connect to Google calendars.

Yesterday I was wrong when I wrote that you had to pay for the Google calendar extension, the one you need to pay for is for the extension to connect MS Exchange accounts. I can get by using Windows 10 Mail for just that one Ex2003 account that I use regularly, since it looks like Tbird will do everything else. If it does the Google calendars well then it can replace EmClient that I currently use for my timesheet calendars. It is not quite as tidy or featured as the EmClient calendars but the functionality appears to be there.

It will be interesting to see if Tbird also handles some of the other Google stuff, or Live calendars, although I can get by without the Live calendars since this is mainly for work computers with Windows 10 that I will be using Thunderbird with to start.

Well since writing the above this morning I have quickly moved to put Tbird on every computer I own or use. The Google calendar functionality is great, it works just as well as emClient although the information is not quite displayed in the same way. There is another extension that synchronises contacts which I am also trialling. Basically, Tbird has superior performance over Outlook for IMAP accounts, although in fact just about everything does, including Outlook Express/Windows Mail. It is the fact it works well across Outlook.com accounts and Gmail as well that makes it highly suitable to my requirements. What it doesn't have is the ability to sync Outlook.com calendars readily and possibly their contacts, but that really isn't much of an issue for me at the present time.

Saturday 29 August 2015

Inkscape Vector Graphics Editing Software

Inkscape stands out as a very good vector graphics editing software package with a breathtaking array of features and functions. Simply finding your way around the user interface is somewhat daunting but gives a clue as to the scope of the development of the project to date and the lengths to which the project has gone in order to create something that is of professional quality yet still completely free.

Vector graphics work in very naturally with mapmaking as the representations of objects on a map are very easily derived from vector graphic objects insofar as they are generally either points or collections of points. The three types of shapefile layers in Qgis are individual points, paths or polygons. A path is simply a series of points with lines drawn between them, while a polygon is an area that has its boundaries defined by points. The shapefile only needs to store the type of object and the coordinates of each point. Because the physical appearance of points (in the case of single point layers) or lines (in the case of paths or polygons) is not hardcoded into the file as it would be in the case of a bitmapped image, the appearance of these can be easily changed on the fly and reshaping a path or polygon in particular is as easy as moving one or more of the points. It goes without saying that vector graphics does not suffer from jaggies when the image is scaled to a different size as it is automatically re rendered to the highest resolution available, thus also great for producing PDFs which are also a vector graphic capable format.

Obviously I prefer to use the GIS rather than Inkscape to draw the maps but I have used Inkscape a couple of times lately to trace overlays on aerial photos and here it was just about as easy to do as Qgis and rather easier than using Google Earth mainly because in the latter case when the output is a KML file, we want the resulting coordinates to be correct and this means we have to try and line up the aerial photo to existing features on the ground as much as possible, which is not always easy to do. As far as the drawing of overlays in Inkscape went, the output was just a picture consisting of the original photo with a layer containing the trace paths overlaid on it. Except for the most rudimentary bitmap editors like MS Paint, multiple layer capabilities are generally available in good graphics editors these days and of course in GISs. 

If there ever was a point where maps needed to be hand edited (for example to replace the presupplied captions from Qgis with ones that can be more randomly positioned) then Inkscape would probably be the package of choice for that task. The main issue at present for such functionality is that Qgis's SVG export is not very good, due to an inherent technical limitation of the Qt application framework that Qgis is built on. When I produce maps for publication I generally am using the PDF export to get a suitable graphic quality. Using Inkscape to open that PDF seems to produce a very good quality result almost indistinguishable from the original, so it may be possible to produce a suitable result, but I have no idea if Inkscape can produce a good output when its SVG is exported back to PDF.

Monday 24 August 2015

SX 170 arrives

So this came down from Smiths City in Nelson, they must have about the last remaining stock in the whole country.

Here it is side by side with the SX150 on its right. There are a few differences which don't really bother me that much. The lens zoom ratio is a little higher as is the pixel count. The styling on the SX170 is reminiscent of a small SLR camera with the flash unit housing resembling a pentaprism shape. It is a little smaller in most dimensions - only to be expected as the lithium battery takes up less space inside compared to the AAs. There is a bigger handgrip on the front and the buttons are more flush with the back of the camera. The 170 has a two speed zoom instead of single speed although the shutter button and thus the zoom ring are smaller. The front, underside and left and right sides are more or less the same, whereas the top obviously has a different shape although the control layout is similar.

We are getting used to Canon continuing with an obsolete Mini USB port on the camera (although the 170, unlike the 150, uses Canon's proprietary integration of the video/sound out contacts onto the plug - backward compatible with the standard Mini B connector). It seems to me Canon is dragging their heels deliberately in regard of introduction of Micro USB connectors, perhaps because the EU regulations will require them to allow in-camera charging through the connector and eliminate a revenue stream from charging accessories. However the new model does include a power adapter capability which the old did not have (due it being on AA batteries).

The battery is not precharged but I was able to get it going quickly by putting in the spare battery from the SX260, as I was aware they use the same battery and this is a good buying point as I won't have to fork out nearly $100 for a spare lithium battery for it.

So this will be my go-everywhere camera for the present and its balance of good price with general photo taking capability in daylight, plus the ability to get good performance in lower light conditions, will serve me well.

Now that I don't have any cameras that use AAs on a daily basis there is just the Speedlite flash for my EOS (originally it was part of a gift with a Powershot S5, I gave the camera away a few years ago) that still needs AAs. And a reminder that I went through truckloads of the NiMH cells - I still have 6 sets of 4 which is partly old ones - the S5 and S1 that I owned each needed a set of four, plus two spare sets were carried and the Powershot As still needed two or three pairs, and each needed a backup set of lithiums as well - and the sets I bought for the Speedlite, which will now have just two sets of Eneloops and a recent set of Panasonics, So all those sets of Vartas and various others that did well for a while but have generally faded away will get the biff. As I said I must have spent a small fortune on AA batteries to keep my Powershots going over the past 10 years and while the proprietary ones are dearer, they have many advantages.

Camera Totals

As of today
  • IXUS135: 2229 - now finished with unless I need to use it for something in the future.
  • SX150: 2881 - going back into mothballs for now.
  • EOS600: 6966
  • SX170: just starting with it (arrived today)
  • SX260: 5496

Friday 21 August 2015

SX170 last of its kind

Six weeks ago I wrote about my plan to get a Powershot SX170 as a replacement for the little Ixus camera I had. I am now following through with that plan as the model has been officially withdrawn in NZ. Fortunately LV Martins / Smiths City still have a few as just about everyone else has sold out.

The Powershot SX170 is now a two year old model. Its replacement was the SX600 which came out a few months after it at the beginning of 2014, although the SX170 was still in production at the time. The SX600 has since been replaced by the SX610 while no new SX170 equivalent has appeared in the Canon lineup. There are quite a few key differences in the SX6xx range compared to the SX1xx range. one of the most important being the lack of manual controls, and the design layout being much more closely aligned to the more expensive SX2xx /7xx series (which does have manual controls, and also a higher spec processor, among other features).

Clearly Canon has determined that the market position previously filled by the SX1xx series as a budget camera with manual controls can now be replaced by a lower spec version of the SX2xx/7xx series with similar overall design. It is interesting how these things go in cycles, in that an earlier series of Powershot A cameras had manual controls before Canon dropped such models from their range - and then reintroduced the capabilities with the SX100 in 2007, while the auto-only versions of the Powershot A range continued for a few more years thereafter. As it turns out, there are no competing models in that price range which also have manual controls, for the time being. 

The main advantage of the SX170 over the SX100-160 range is the use of lithium batteries in the 170 which frees one from the tyranny associated with AA batteries that have no battery level meter available and have an all-too-common tendency to go flat at the most inconvenient time due to loss of capacity. Naturally I have found the Eneloop batteries the most dependable in that regard, but have lost track of how much I have forked out for in batteries over the ten years since I bought my first AA battery camera, the Powershot S1. That included a couple of Maha Powerex fast chargers to bring the batteries up to charge quickly since standard chargers are uninspiringly slow with their 16-18 hour cycle time. 

So I guess I will have this thing next week and away we go.

Sunday 26 July 2015

Canon SX150, Lowepro Dashpoint 20 & Lowepro Apex 60


Once upon a time... Lowepro made the D-RES series of camera pouches. I had one of the smaller ones. It held every one of my AA battery pocket cameras and had plenty of internal pockets for extra batteries. With the AA cameras I had a spare set of rechargeables and a spare set of lithiums to cover the all too common loss-of-capacity-without-warning eventuality of AA rechargeables.

Then Lowepro stopped making the D-RES, and mine wore out. And Lowepro's more versatile bags with internal pockets were all focused around the ultra-compact end of the market. Canon make a great camera in the SX100-150 series, but there isn't any longer a bag that has internal pockets and fits the camera easily.



On the right there you have a Dashpoint 20, about the smallest pouch that will fit a SX1xx. But, there are no pockets except for a small elastic one for a spare memory card. So no room for spare batteries.

What else is available? Well I tried a few different things. The latest is seen on the left - the Apex 60. It's very nice, but as you can see it's a lot wider. The size of it is an embarrassment to carry on your belt compared to the camera, which will fit in the pouch two directions with lots of spare space. It is designed with the Canon GxX series in mind, which is significantly larger.

The problem with Lowepro's range is there aren't a progression of sizes. The similar Apex 20 and 30 models are nearly the same size, then there is a big jump to the Apex 60. 

Bearing in mind I am using an SX150 at the moment until I decide what should replace it, I am using the Apex 60 until I work out the answer to that question. That may well be the SX170 back in the Dashpoint 20 or something smaller, again.

Thursday 9 July 2015

SX150 again

So back to using the SX150 for the first time in 20 months and it's great to be using such a good camera again. One of the reasons I stopped using it is because I couldn't get a pouch that would hold two additional NiMH AAs as well as two lithium AAs for "emergency" backup. But I will get by for now with just the two extra NiMHs. I have just bought a 4 pack of Eneloops to make sure I have some that will give me a decent amount of charge capacity, and they can also be used in the Speedlite flash that I have for my EOS so they will not be wasted. 

Yes it is great to be using this camera with all of the features it provides and the picture quality may not be as good as some other cameras but you don't care so much about that in that sort of price range. Even with the ISO bumped to 1600 for taking photos at dusk, I am reasonably happy with the kind of photo. Noisy yes but you expect some sort of issue for getting handheld photos at 1/13 of a second in that kind of lighting, otherwise you would use a tripod. I am more concerned that some of my photos taken in low light conditions were a bit blurry. Well, the manual focus would take care of that.

One of the advantages of a lithium battery camera which I had forgotten about is a proper battery meter. When I picked up the 150 I noticed, no battery meter display. It wasn't until the unexpectedly short shooting time for what must have been a set of batteries with insufficient charge reared its head, that I remembered that on these AA battery cameras, all you will get is a flashing red "battery low" symbol and that is all. There is no battery meter whatsoever that will give you any advance warning, which is partly the reason why I used to carry a set of lithiums in addition to the spare rechargeable set with my AA battery cameras. It's one more compelling reason to push on and get the 170, or if it happens first, a successor. The 170 is now almost two years old, and it's still using the same dated Digic IV chip that the 150 had, which is becoming a focal point of independent reviewers. OK, I don't expect to see the same technology as the SX2xx at twice the price so fair enough but at some point they must be going to update the processor and maybe the sensor (CCD as compared with CMOS in a lot of modern cameras). Then again at that price point there have to be some compromises.

Wednesday 8 July 2015

How to set the image number you want on a Canon camera

As we all know the Canon cameras number images sequentially and this counter can be useful to know how many images you have taken on a camera. However when you take a memory card that has been used in a different camera and put it into your camera, the counter gets reset according to the last numbered image on the card, rather than according to the last number it used when it took the previous picture.

However by following a simple procedure you can change the counter in the camera to whatever you want when you put a new card in the camera. (Note I do recommend each camera has its own cards so as to avoid these problems if you swap cards between cameras).

  1. Format the new card in the camera and take a photo with it.
  2. Take the card out and put it in a card reader on a computer.
  3. Rename the image to the correct number e.g. IMG_xxxx.jpg
  4. Change file numbering in the camera menu to auto reset
  5. Put the card in the camera and take a photo. This new photo should have the correct number.
  6. Change file numbering in the camera menu to continuous
  7. If you need to put another card into the camera then format it in a PC before you do so, so that there are no images already on it, otherwise the problem will repeat itself.

Replacement for Ixus 135 Camera - SX170IS

Around 20 months ago, beginning of October 2013, I bought my very first Ixus, the 135 in a very fetching blue colour. The Digital Ixus series of cameras were first produced by Canon in 2000 and like some other Canon models the name was previously used on a series of film cameras. The Ixus has gained a name for itself as a solid high quality metal bodied compact camera. It was kind of inevitable though that Canon would rationalise its low-end camera ranges and the Powershot A series which was basically plastic equivalents of the Ixus, have been phased out. But instead of keeping the traditional metal body of the Ixus, the new models are now plastic and definitely aimed at the budget market. Since my 135 is now playing up, with a lot of lens errors occurring for no obvious reason, I will have to replace it soon. 

My choice of replacement will be the SX170IS, which is rather larger with a much longer 16x lens. It is a descendant of the SX150 which I have had mostly in a cupboard for the past two years. The 170's main advantage over the 150 is the switch to lithium batteries which although proprietary, make the camera smaller and easier to use and hold their charge very well. I had used AA battery Canons for so long that I was very anti anything else, but I have made the jump across to lithiums quite strongly in the last few years and now I don't want a bar of AAs at all. Both models are otherwise quite similar with the PASM exposure modes and manual focus being strong points of the design. It lets you have a fully manual capable camera at quite a good price even if its low light perfomance and burst speed, among other features, aren't super hot. 

But while I am saving up for the SX170 at around $250, I will be going back to using the SX150 for a while. It means having to carry extra AAs with the camera which is annoying but that is what will have to happen for a few weeks anyhow. Once upon a time the Powershot A series cameras were all the rage as a camera range that were all AA based but as time has gone on the use of AA batteries in these cameras has gradually diminished to the point the A series had all gone lithium about three years ago and the SX 1xx series looked a bit odd as a reversion to AA battery power. Now even this series has changed over to lithiums and there are no AA battery cameras left by Canon at all. When I got my Powershot S1 ten years ago the fact it used 4 AAs seemed almost normal but now it seems quite dated. The Fuju Finepix cameras however continue to use AA battery technology in a number of series, most notably the ultrazoom S range, with no sign of diminishing this trend in the near future. When I bought my Powershot S1, a Fujifilm S series was the main competitor, and I was pleased I forked out a bit more for the S1 as it was undoubtedly better than the Finepix which was a bit cheap and basic in its design, but quite popular amongst the more cost-conscious and less quality-discerning camera user community. I think it was the S5000 that was the equivalent model to the Powershot S1 at the time, one of its unfortunate features being the lack of a lock on the battery door that could cause it to disgorge its contents at a mere bump. Yes, I chose the more expensive Canon and have never purchased any other brand since.

So of course I will want to get switched to the SX170 as soon as I can but naturally it has to wait until I can stump up the dosh for it. But it will be good to go back to a fully manual capable camera in my belt pouch again which has only been possible in the last 10 years with the SX150 as every other camera I have carried therein has been auto-only capable. These have included the Powershot A400, A450, A460, A2000, A2300 and the Ixus. One of the reasons AA batteries have fallen out of favour in the compact camera community is their low current delivery, typically this results in quite slow flash recharge times. Another of course is the bulk which makes smaller lighter cameras harder to deliver. The Ixus range has always used proprietary batteries as well as of course the EOSs, so I have no real difficulty with that design aspect becoming more established but the batteries are relatively expensive to buy and you need to make sure you have a spare if you don't want to get caught with a flattie.

Monday 15 June 2015

Manipulating object tables in Powershell.

Last week I posted about creating object tables in Powershell. This was mainly for the purpose of being able to use Export-CSV to send the data out to a CSV file. This time I am going to have a brief look at some of the other things you can do with an object table, which is a convenient way of having a simple database that you can store data in and process it through your script.

Since the object table is basically an array of objects, it can be manipulated using the basic array operators. Such as:
  • Append an instance: += which most people will recognise as the standard increment operator borrowed from C/C++.
  • Retrieve an instance by index: e.g. $S[0] returns the first instance
  • Retrieve a range of instances by index e.g. $S[4..9], $S[1,2+4..9]
  • Retrieve the last instance: $S[-1] which is great as you don't need to know how big the array is to use this.
Obviously we don't need to use typical database methods like First, Last, Next and Previous which are often provided to step through a table's records. Instead just index the array.

Friday 12 June 2015

Three Jaycar Torches


I have found torches purchased from Jaycar to be the best quality and useful LED small torches that I have owned lately. On the right you have a small pocket torch that has a slide-zoom head and runs on 3xAAA batteries (similar to ST3483). In the middle a more powerful equivalent with a twist zoom and the same level of battery power (ST3475).

The head torch (ST3279) is my most recent purchase and runs on the same amount of battery power. It has a slide zoom head and is waterproof. This replaces an older Jaycar head torch which had a separate battery pack mounted on the back of the head on the strap, the problem with this one was that the connecting wire broke off after several years of faithful service. There is a problem with the new headtorch and that is the red translucent band that is incorporated into the head. The LED shines through that which creates a prominent glare issue when wearing the torch on the head. So I will have to get some black paint to put over the band to block the light from going through it.

Thursday 11 June 2015

Creating object tables with Powershell

One of the useful things you get with Powershell is lots of functions that create data tables in memory that you can cycle through using Foreach to get an instance (equivalent to a record or row in a regular database) and then interrogate its properties (equivalent to columns). The Foreach loop automatically steps through all the object instances in the table.

Having done a number of function calls (for example Import-CSV to get a list of users from a CSV file, or Get-ADUser with a search spec to retrieve a bunch of user accounts) I thought it was about time I worked out how to create an object table myself, so that I could populate it with some user account data and then write it all out to a CSV file, using Export-CSV in this case. 

Well it turned out to be exceptionally simple to do this. Basically, object tables are just arrays of objects. Here is some code to illustrate this.

$UserList = @()
foreach ($Class in $Classes)
{   
$ADStudents = Get-ADUser -Filter  {Division -eq $Class} -SearchBase  "ou=Students,ou=School,dc=our,dc=school" -SearchScope Subtree -Properties ipPhone   
if ($ADStudents -ne $null)   
         foreach ($S in $ADStudents)
        {           
$username = $S.samAccountName           
$pwd = $S.ipPhone           
if ($pwd -eq $null)           
{               
    $pwd = ""           
}           
$UserList += New-Object psobject -Property @{Class = $($Class);Username=$($Username);Password=$($pwd)
}        
}   
}
}
So in this script, which loops through a set of classes ($Classes is an array of names of classes) the first line is to create the table itself, with no rows and no columns just yet. This is the simple $UserList = @() call which is actually creating an array.

Then the first Foreach loop is to go through a predefined array of class names for the school, and it gets the name of the current class into $Class. Then it gets all of the student accounts which have that class specified in their Division property. Note that it also retrieves the IpPhone property, which is used to store the passwords that we want to have a list of.

So the next step is to find out if we retrieved any results, and if so, another foreach loop has the task of getting each instance in turn (because the results of the Active Directory call are returned in an object table themselves) and then we add a row or record to $UserList. Firstly we create an object instance in which to store the data, and then we specify that the properties of that instance are Class, Username and Password, and the values they contain. 

It's useful to note here there is no fixed structure for each row, because each row only needs to be an object, and each row could easily refer to a different object structure, with different property names. This is a key difference from a regular database which predefines column names and types so they are consistent throughout the dataset. Obviously I am keeping things simple here and making every object instance identical.

So that is how we create our table, and the final line of the script (not shown) is a simple call to Export-CSV to write out the table to disk. 

Sunday 31 May 2015

Nokia Lumia 635 a worthy replacement for Lumia 520

Not quite two years ago I blogged that I was getting a Lumia 520 phone, which was thrown in free with the Smart 45 plan I was on. The Lumia 520 held up quite well; it got dropped more times than I would have liked, but spending most of its time in a pouch meant it was relatively well looked after. In the end it was a faulty power button that has seen it put in storage as a standby spare (the phone can still be turned on with the hardware camera button).

The replacement, which I paid for, is a Lumia 635. This model has a slightly larger screen with Gorilla Glass instead of the generic glass on the 520. About three months ago MS started shipping the 635 to NZ with 1 GB of RAM instead of the original 512 MB. This makes it more suitable for Windows 10 when it arrives. The screen is slightly larger with a few more pixels, the battery is a little larger, the CPU is quad core instead of dual, and it supports 4G. And that's about all - and you pay $149 for the handset compared to $99 now for the 520. I think the screen is probably brighter and therefore better in sunlight. I felt that the 635 being a bit dearer would be a better phone, and with 1 GB of RAM I think it is.

The big difference is in body styling. The 520 has a curved back, and the edges are all curved as well at the rear of the phone. The corners seen from the front are relatively square, with very tight curvature. The 635 has a mostly flat back with straight (although slightly tapered) sides,  and the corners are quite wide. Overall I like this appearance much more.
 Side by side the 635, 520 and the old HTC Trophy 7 which was my first smartphone.


 Seen from the rear view.

The 635 also has changeable covers like the 520. In this case the colours are green, orange, black and white. The phone comes from the shop as black. Ascent supplied a green cover for just over $20. The green is very bright and glossy - it is grass green and I love it. It really adds to the character of the phone and makes it fun to use. I think the cyan blue for the 520 was a bit bland and red would have been a better colour to have had, although I can see the attraction of the blue.

The 635 was easy to switch to in the shop and the SD card fits into a slot in the battery bay just as in the 520. It was easy to back the old phone up onto OneDrive and then restore it onto the new phone. So it was pretty much all go within a couple of hours.

Thursday 7 May 2015

Using Powershell to monitor AD account creation

http://community.spiceworks.com/how_to/76915-automatic-report-about-newly-created-user-accounts-to-an-e-mail

Here’s a neat article about how to monitor event logs on a domain controller that cause a script to run whenever a new user account is created. The main limitation I see is it will only work on the DC that the account was created on. We really need a generic one that will work on any DC. Other than that, it’s a great idea that I will do some testing on soon.

Friday 24 April 2015

Logitech M185 Wireless Mouse

Well after the struggle of another Microsoft mouse that didn’t do what was advertised, I purchased a Logitech M185 – allegedly the successor to the M215. And what a brilliant progression it is. The M185 is more like the MS Mobile Mouse 3500 – refreshingly basic and cheap, retailing around $25 – but without the hassles. It seems to work best with the dongle in the front USB port closest to where the mouse actually is. The “ratcheted” scroll wheel makes it easy to middle click as does the lack of a tilt wheel. You just can’t go wrong with these basic Logitech mice and as they say they have been in the mouse business longer than anyone else.

Tuesday 21 April 2015

Microsoft Sculpt Mobile Compact Mouse

I’m trialling one of these as a replacement for the Mobile Mouse 3500 I purchased six months ago. The MM3500’s main problem was simply that it would become bogged down when the computer was busy and therefore be difficult to use at that time. The SM is in its physical shape virtually identical to the MM with one small difference – the Windows button behind the wheel that brings up the Start screen, or when running Classic Shell, the Start menu. The price is about 50% higher, which I hope leads to a better performance – the MM never had any real issue such as tracking on a smooth desktop (as even a Logitech laser mouse did), it was the jerky movement of the pointer at certain times that made me eventually give up on it, although losing the receiver a few months ago means it’s been gathering dust on the shelf ever since. It’s naturally a great pity you can’t buy replacement receivers but greed rules supreme from the manufacturers of course.

Like the MM, the SM has a click scroll wheel with detents – which is important when you want to middle click. The problem with continuous scrolling wheels is how hard it is to click the wheel as a button. Unfortunately we end up having to rely on reviews to find out which kind of wheel a mouse actually has.

UPDATE: Unfortunately I have been sadly disillusioned by seeing the exact same problems in this mouse as its predecessor. I honestly cannot understand why a company with Microsoft’s reputation can overlook such a glaring fault in their cordless mouse hardware. For three days I used a Logitech cordless laser mouse on the very same computer and it never missed a beat. The Microsoft blue-light mice of this particular design seem to all have the same problem in that the mouse will simply freeze whenever things get a bit intense and then jump a great distance across the screen when it catches up. I am forever finding I have to use the same trick of taking the mouse up off the surface to reset it when it jumps around too much. Just junk and I am not buying another MS cordless again.

When I checked the reviews on Amazon I should have read all the reviews because some of the reviewers reported exactly the same problem. We live in an age where manufacturers simply cannot be bothered producing a quality product anymore. And in a society where the environment and waste are becoming an issue, these companies just keep on producing cheap junk that only last a short time and then gets thrown away, being wasteful of resources. The Logitech M215 was what I had a play with at the weekend and the M185 which I believe is its replacement is probably the one I will try next.

Saturday 28 March 2015

Detecting file change management in PowerShell

For some time Windows has supported in the Win32 API various events that are triggered when files or directories in a filesystem are changed and this appears to be supported in .NET as well. This then leads us to a natural question of whether we can support that in PowerShell. Due to PowerShell being essentially a scripting extension to .NET, we indeed can use these capabilities in our scripts.

After looking on the internet it appears from several sources mentioned below I can have a script that looks something like this:
$watcher = New-Object System.IO.FileSystemWatcher
$watcher.Path = $searchPath
$watcher.IncludeSubdirectories = $true
$watcher.EnableRaisingEvents = $true


Starting off here the FileSystemWatcher object is instanced for this script and parameters have been passed to define the path to be searched and whether to include subdirectories. The last line tells the FileSystemWatcher to raise an event when a change is detected. 


$changed = Register-ObjectEvent $watcher "Changed" -Action {
   write-host "Changed: $($eventArgs.FullPath)"
}
$created = Register-ObjectEvent $watcher "Created" -Action {
   write-host "Created: $($eventArgs.FullPath)"
}
$deleted = Register-ObjectEvent $watcher "Deleted" -Action {
   write-host "Deleted: $($eventArgs.FullPath)"
}
$renamed = Register-ObjectEvent $watcher "Renamed" -Action {
   write-host "Renamed: $($eventArgs.FullPath)"
}
This section registers the event handlers for different types of events that are raised. Once this piece of code has executed then these actions will be fired each time the FileSystemWatcher detects a notifiable activity.

Unregister-Event $changed.Id
Unregister-Event $created.Id
Unregister-Event $deleted.Id
Unregister-Event $renamed.Id
Finishing off here with unregistering the event handlers and there should also be a call to dispose of the $watcher object or at least disable it when no longer needed. Closing the PowerShell session will have the same effect.
The source for this script came from here: http://dereknewton.com/2011/05/monitoring-file-system-changes-with-powershell/

There is a comment to that article mentioning the Change event can be fired multiple times for the same file depending on how the application doing the change works with the file. To limit the firing of multiple events some other kind of code may be needed in an event handler to determine whether the file is currently opened or closed by the application which is writing to it. I still have to do some testing with the setup I am looking at to determine how these events would be fired and which events to use. An option is to have the creating script rename the file once it has finished with it and the rename event will then be fired.

Well, testing it works more or less as expected. One major issue to be aware of is to do with errors; the code inside the braces for the Action won’t be evaluated by the Powershell ISE for syntax errors and if a mistake occurs in execution the usual messages on the Powershell console window will not be displayed. So we really only have the option of live testing. The situation I am working with uses a script that causes an email to be sent to a group whenever the action files, so I will be watching for emails coming in for sure.
 

Using PowerShell to manage Google Apps

With the limitations of Google’s console to manage Google Apps for system admins, scripting and command line tools have naturally become a topic for the system admin community. Previous posts here have discussed the options for use of various tools and so far I have used both Dito GAM and PowerShell with extensions as a Google Apps management tool. Dito GAM is a command line tool specifically and is well suited for batch operations managing many aspects of Google Apps. It is well thought out, completely free and proved quite invaluable for managing our first Google Apps deployment in a New Zealand school.

However it does not specifically integrate to PowerShell in the way that a PowerShell extension would be capable of achieving as it is a separate executable application and so I have more recently looked at the gShell extension module to accomplish scripted tasks within PowerShell in a different school. Having mentioned various PowerShell extensions that were available in an earlier post, gShell has been the one I have focused on to date and it has a supportive user community and open development model which has made it easy to implement to date.

I now turn specifically to some of the tasks I have achieved in Google Apps experimentally to manage specifically the synchronisation of user accounts between Active Directory and Google Apps so far. The scripts examined in this post are:
  • Provision-Students: Provision accounts in Google Apps from Active Directory
  • Classify-Students and Reclassify-Students: Organise student accounts in Google Apps to match the class structure of the school
  • Deprovision-Students: Move accounts of non-current students to a different suborganisation in Google Apps.
Provision-Students
Provision-Users is a simple script that generates accounts in Google Apps based on the list of accounts it can find by searching a specific tree in Active Directory.
import-module ActiveDirectory
import-module gShell

#Retrieve all students from Active Directory
$ADStudents = Get-ADUser -Filter * -SearchBase "ou=Z,ou=HCS Students,ou=HCS,DC=hcs,DC=local" -SearchScope Subtree -Properties EmailAddress
foreach ($S in $ADStudents)
{
    # Check account is enabled
    if ($S.Enabled -eq $false)
    {
        continue
    }

    $Email = $S.EmailAddress  
    if ($Email -eq $null)
    {
        Write-Host ($S.SamAccountName + " does not have an email address set. Skipping.")
        continue
    }
In the first section of the script we are searching AD using a subtree filter and it has used one specific OU (named for for students whose surnames start with Z) but it can use a higher level OU to search multiple lower levels. We have to specify in the query that the EmailAddress is being returned from the query as it isn’t one of the default user object properties that are returned from this cmdlet. After checking the account is enabled and has an email address set we can fall through to the next section of the script, otherwise that user account is skipped.
   #Look up in Google Apps
    Write-Host ("Looking up Google Apps for " + $Email + "...") -NoNewline
    $User = $null
    try
    {
        $User = Get-GAUser -UserName $Email -ErrorAction Stop
    }
    catch
    {
    }
    if ($User -eq $null)
    {
        #Add if not there
        New-GAUser -UserName $Email -GivenName $S.GivenName -FamilyName $S.Surname -PasswordLength 8 -IncludeInDirectory $true `
        -OrgUnitPath "/Students From AD" -ChangePasswordAtNextLogin $false
        Write-Host ("Added " + $Email + " to Google Apps")
    }
    else
    {
        Write-Host ""
    }
}
The rest of the script is concerned with finding an account in Google Apps and creating a new account if the existing one isn’t found. Get-GAUser will throw an exception if the account isn’t found so I have to catch this with a try-catch block although I could also have used a Trap block. I haven’t tried to determine which exception is being thrown and occasionally there will be an instance of an exception even though the account does exist indicating some other type of exception other than “not found”. This results in an error in the next section in these few cases. The code around this block assumes the $User instance will be null if Get-GAUser doesn’t find the account. The last section simply calls New-GAUser to set up the new account. We didn’t specify a password and have let Google create a random one. Later we will provision passwords into Active Directory and let Google Apps Password Sync automatically provision them into Google Apps, so this isn’t an issue.

Deprovision-Students
A simple script that moves students accounts to a different sub organisation in Google Apps if they are not found or disabled in AD.
import-module ActiveDirectory
import-module gShell

$PC = New-GAUserPropertyCollection
#Retrieve all students from Google Apps
$GAStudents = Get-GAUser -All

foreach ($G in $GAStudents)
{
    # Skip if they are not in the Students organisation
    if ($G.OrgUnitPath -notlike "/Students From AD*")
    {
        continue
    }

    $Email = $G.PrimaryEmail
    # Look them up in AD
    $ADStudents = Get-ADUser -Filter {EmailAddress -eq $Email} -SearchBase "ou=HCS Students,ou=HCS,dc=hcs,dc=local" -SearchScope Subtree
    if ($ADStudents -eq $null)
    {
        Set-GAUser -Username $Email -PropertyCollection $PC -OrgUnitPath "/Students Not In AD"
        Write-Host ($Email + " is not in AD")
    }
    else
    { # If found but disabled then move them as well
        foreach ($S in $ADStudents)
        {
            if ($S.Enabled -eq $False)
            {
                Set-GAUser -Username $Email -PropertyCollection $PC -OrgUnitPath "/Students Not In AD"
                Write-Host ($Email + " is not in AD")
            }
        }
    }
}
We are using Set-GAUser to move the account in Google Apps. Due to a bug in this cmdlet we have to create a redundant GAUserPropertyCollection object and use that in our calls. It is important if you use the extra properties in your Google Apps accounts to make sure that calls to Set-GAUser do not erase these properties by passing an empty instance (as in this case). I don’t know if this is a risk or not because I haven’t checked in the documentation to see what happens in such a case.

Classify-Students / Reclassify-Students
These two scripts are both concerned with reorganising students between different sub organisations in Google and are essentially identical apart from one line which I will mention below.
import-module ActiveDirectory
import-module gShell

$PC = New-GAUserPropertyCollection
#Retrieve all students from Google Apps
$GAStudents = Get-GAUser -All

foreach ($G in $GAStudents)
{
    # Skip if they are not in the Students organisation
    if ($G.OrgUnitPath -ne "/Students From AD")
    {
        continue
    }


    $Email = $G.PrimaryEmail
    # Look them up in AD
    $ADStudents = Get-ADUser -Filter {EmailAddress -eq $Email} -SearchBase "ou=HCS Students,ou=HCS,dc=hcs,dc=local" -SearchScope Subtree -Properties Division
    if ($ADStudents -ne $null)
    {
        foreach ($S in $ADStudents)
        {
            $OrgPath = "/Students From AD/" + $S.Division
            Set-GAUser -Username $Email -PropertyCollection $PC -OrgUnitPath $OrgPath
            Write-Host ($Email + " moved to " + $OrgPath)
        }
    }
}
These scripts only differ in the Google Apps OrgUnitPath which in the Classify script doesn’t have the wildclass * on the end of it and in the case of Reclassify, does. The former script is for first time classification of new accounts and the second for reclassifying existing accounts but you could just use Reclassify for both functions, however if you have a lot of accounts it needlessly wastes time calling gShell to essentially do nothing to the account since it doesn’t need moving. (Note however my comment about GA-UserPropertyCollection objects from the previous scripts)

We use AD calls here to retrieve the classification property (in this case the class that the student is enrolled in) and move the account in Google Apps to a sub organisation named after that class.

Sunday 8 February 2015

How to edit file system permissions in Powershell

http://blogs.technet.com/b/heyscriptingguy/archive/2014/11/22/weekend-scripter-use-powershell-to-get-add-and-remove-ntfs-permissions.aspx

ScriptingGuy in this blog has dealt with and ably addressed the various limitations of the original system of setting permissions in Windows using Powershell, which was that you had to manipulate ACLs, never particularly easy, and also had the horrible 260 character path abortion of Windows 32 API to contend with. By providing the NTFSSecurity module, permissions have become much easier to configure in Powershell. All this is great because I have some permissions work to do in some of my scripts. Even on my home computer I would like to set permissions with a script command rather than muck around with Windows Explorer (waiting for it to update all the permissions on a big folder is quite time consuming).

Thursday 5 February 2015

Powershell Community Extensions and Carbon

What makes Powershell so useful is not only the excellent built-in capabilities, but the various extension modules developed for it by third parties. Last time I talked about some Google Apps extensions, which I am currently testing and look very promising. Today I am going to take a quick look at Powershell Community Extensions and Carbon.

Powershell Community Extensions, according to the ScriptingGuy blog, fills in some gaps in the general purpose cmdlets in Powershell, because Powershell is a relatively new scripting environment. To wit: 
"PowerShell Community Extensions is a PowerShell module that provides a number of widely useful cmdlets.  PSCX is not affiliated with Microsoft or the Windows PowerShell team at Microsoft.  We are a few (at the moment) passionate PowerShell users who wanted more cmdlets than Microsoft was able to deliver in v1 and v2.  So we have taken it upon ourselves to create some of those cmdlets and make them available to the community."
 There are quite a number of cmdlets added by the current release of PSCX (v3.2) which encompass quite a number of useful functions. Some of the ones that I found interesting include 7-zip archive management, file junction management, email send, terminal services sessions management and VHD mounting.

Here is the description of Carbon from their website:
Carbon is a DevOps PowerShell module for automating the configuration of Windows 2008, Windows 2008 R2, 7, 2012, and 2012 R2 computers. Carbon can configure and manage:
  • Local users and groups
  • IIS websites, virtual directories, and applications
  • Certificates
  • .NET connection strings and app settings
  • Junctions
  • File system permissions
  • Hosts file
  • INI files
  • Performance counters
  • Services
  • Shares
  • Windows features/components
And much more!
 Again you will notice junctions are featured - and that one of my current scripting project uses junctions. I got to hear about these two projects because of the junction extensions. It will be interesting to see how useful these extensions are as I develop and test my script.

Tuesday 3 February 2015

Managing Google Apps with Powershell

You don't have to be too knowledgeable about computing to know Microsoft and Google are at each other's throats constantly in the IT world. Fortunately, that doesn't extend to every level, and so it is with some pleasure I have started to investigate the ability to use Powershell to provision and manage Google Apps for Education.

When I first started managing Google Apps domains for schools I went out looking for a useful management tool to do bulk account management (since Google doesn't provide for this in their admin console) and after a time discovered the Dito GAM tool (Google Apps Manager). Since then I have used it to perform some aspects of account management, which included bulk account suspension when the accounts we had created for students weren't immediately required. Whilst this tool has proved very versatile it lacks capability to be useful when called in scripts and also can't manage the Google Apps shared contacts (we need something to manage this because it is another capability lacking in the Google Apps console).

So at this point I am starting to look at Powershell extensions to manage Google Apps instead. Assuming they conform to Powershell conventions and interoperability they will be usable in Powershell scripts that I write and can therefore be easily integrated into the student add script I am working on. So far here are some tools I have found and will be evaluating:
Of these, GShell looks the most promising. GDataCmdLet is currently the only one of the three that supports contact management, but hasn't been updated since 2010.