Sunday, 26 November 2017

Powershell Symlink to Onedrive

I have more than one PC. To be precise, and overly pedantic, 3 Windows 10 laptops. All are slightly different and of various ages. One I use with a Windows 10 Insider Build to keep up with the next thing coming down the pipeline. On each, I do a bit of Powershell.

Powershell is the latest generation of Windows command line tools. The Linux enthusiast would look down on the Windows command line of whatever generation but Microsoft has always provided command line tools.

In the early days MSDOS was a command line OS. It did little but create directories (folders), copy, move or delete files. It ran “” which some said was just a basic file system manager and way of loading programs into memory. It wasn’t difficult to disagree. Developers brought out alternatives to this such as 4DOS, literally “for dos”, by JP Software. They also produced 4NT, which enhance the Windows NT command processor and 4OS2. The latter was for the IBM OS2 Operating System of the late 80s and early 90s. Years ago I visited JP Software, then based in Boston, and got to meet Tom Rawson who ran the whole thing at the time. Although to be fair I should add the principle developer was Rex Conn.

However, I digress quite considerably. The main point is that the command line, for many users of Microsoft operating systems, became quite powerful and many attempts were made to turn it into a scripting tool. The advantages of scripting, as opposed to programming, was that regular administrative tasks on a PC could be automated. Engineers could set up processes that repeated steps at a specific time or over a range of machines.

Microsoft got the scripting bug too. VBSCRIPT became a scripting language used by many. However, it was a bit clumsy because it was tied closely to the Windows GUI and not really to the command line. This often meant an uneasy use of object orientated programming in places where engineers wanted simple procedural choices to get stuff done quickly.

This brought the world to Powershell. Microsoft’s command line interface that allowed you just to type commands, process text files, setting up common configurations and much more. Mostly it let an engineer write a few lines of commands that did everyday tasks quickly. It was also extended into many of Microsoft’s core business products like Sharepoint, Exchange and Lync. It is everywhere and having a bit of Powershell knowledge is a good thing.

Keeping my personal Powershell library of stuff easily backed up and automatically updated has been a challenge. By default a folder is created at “c:\users\username\documents\windowspowershell” and your startup scripts are dumped there. (You replace “username” in the example with your own login name in Windows to find this location because I am doing a generic example here).

If you install Onedrive sync on your PC then you end up with a path to your documents of “c:\users\username\onedrive\documents”. The obvious issue is that your Powershell settings and default script location is local rather than synced in the cloud. The easy solution to syncing everything up is to do what Unix/Linux guys have done for years – symbolic links. You put a link in your local document folder pointing to Onedrive.

1. Run cmd.exe as administrator.
2. Go to “c:\users\username\documents\” on the command line and rename “WindowsPowershell” folder. Use the RENAME command. Use any name you like.
3. Once the folder is renamed create a symbolic link with the command “mklink /D WindowsPowerShell C:\Users\username\OneDrive\Documents\WindowsPowerShell”

That’s it. Your local Powershell reference actually points to Onedrive now. Remember “username” in this example has to be replaced with your actual computer username.

Repeat on all your PCs and your Powershell scripts will follow you around your PCs.

Sunday, 5 November 2017

Being progressive rather than universal

Microsoft was not short of ambition for its tiled interface and One Windows strategy. Microsoft was doing what no other tech firm had done - uniting mobile to desktop/laptop PCs in one experience. Apple had two OSs available - IOS for phone/tablet and OSX for its desktop/laptop users. They were different and had different interfaces. Google had two OSs - Android for phone/tablet and ChromeOS for its Chromebook devices.

Of course, even One Windows doesn't mean exactly the same OS but it does mean components have such similarity that the interface appears the same to users and, with little modification, apps can run on all platforms.

Unfortunately, the app platform UWP (Universal Windows Platform) was hobbled from day one. Microsoft had a poor quality application store, ever-changing developer tools and standards and a Store that only worked (on the PC side) for Windows 8 and latterly Windows 10. While people used legacy versions of Windows such as Windows 7 and XP the apps were "invisible". They also kept rebooting WindowsPhone from 7 to 8 then 8.1 and 10. Each iteration became a year zero where developers were faced with re-writes.

UWP also became fragmented. Developer "bridges" allowed conventional WIN32 legacy apps to be delivered in a UWP "wrapper" to aid installation. There was also a wrapper so that websites could be delivered as an "app" but were just launching a web connection. UWP became more of a way of distribution via the Store and adding notifications rather than being universal. Microsoft's interest in phone waned as they retreated from successful markets turning them into unsuccessful markets. It literally appeared their ambition was to achieve zero sales in mobile.

You can't have a "universal" platform if your universe consists of just the PC!

Just as Microsoft abandoned mobile devices, affected greatly by the dearth of good apps, PWA arrives.

Progressive Web Apps (PWA) are the force that makes apps unimportant. A PWA is a website that has components that run on a smartphone like an app. For most people they will act like an app. They can be pinned to home screens and may even work offline. Mechanically a PWA has "manifest" of components that make it work online or potentially offline using the web.

There will be some applications like CAD, Photoshop and games that will need to run natively on the device they are coded for. However many phone "apps" can become progressive and can work across any device. Google and Microsoft are onboard with the concept. The next Windows 10 update with Edge will support PWA. The Windows Store will be able to wrap PWA "apps". Maybe even Windows 10 Mobile devices could run PWAs and then have parity of function with Android devices.

There is irony here. Could it be that Google backing for PWA makes Windowsphone viable?