PowerShell

Update to Windows 8.1 from Windows 8

Before you decide to upgrade your Windows 8 to 8.1, you should be aware of some issues/changes.

To begin with, it is not very obvious and easy to find a way, to avoid using Microsoft Account. Fortunately, Scott Hanselman described it in his blog, in his post How to sign into Windows 8 or 8.1 without a Microsoft account – make a local user.

Another issue is SkyDrive. If you are not using it, then you do not need to worry. But if you do (like me) then be aware that now it is integrated with Windows 8.1. You are not able to use SkyDrive app like in Windows 8. What is more: you need to sign in with Microsoft Account on Windows 8.1, to be able to use SkyDrive. In the recent version of SkyDrive, Microsoft introduced “smart files”. It distinguish two types of files: online-only (not stored on your hard drive and available when you are connected to the Internet) and offline (old-style files, can be used when you are offline and will be synced once you get online). Default status of new created file is online-only. You need to change it if you want to use files in the old-way (offline). There are two ways to do that. First: go to SkyDrive app and mark file/directory you want to make offline (by right click) and click “Make offline” in app bar:

SkyDrive - make offline

Second way is go to SkyDrive settings and set “Access all files offline” to “On”:

SkyDrive - access all files offline

You can find more details about “smart files” here.

All above issues are fixable. However there are a few things, which cannot be solved (so far). I have ThinkPad X220 (i5@2.3GHz, 8GB RAM, 160GB SSD) and I did a system upgrade from Win8 to Win8.1. Since then, the performance is a little bit worse. Additionally, I have two monitors connected through VGA and DisplayPort. The second monitor is all gray right after system boot. I need to click WIN+D to get the desktop. I do not have this issue on my PC where I installed Win 8.1 from scratch.

I use PowerShell as my default command line. There is a weird issue with Lucidia Console font on Windows 8.1. You cannot set it as default font. It is not a huge concern, because the Consolas works fine, but I cannot use Lucidia Console (which I like better). More about this issue here.

Now, let’s look at the bright side of life. My favorite Windows 8.1 feature is “search everywhere”. You do not need to think whether you want to search programs (WIN+Q), settings (WIN+W) or files (WIN+F). However, Everything Search Engine is still the best for searching files.

I like the Windows button too. After right-click, you have the same menu which you get with WIN+X. Furthermore, there are options shutdown/restart/sleep there. It is easier and faster accessible than “Mouse to right-bottom corner of screen”->Settings->Power->Shut down.

Another nice feature is the adjustable size of tiles:

Windows8.1 - adjustable tiles

To learn about other new features I recommend Scott Hanselman’s videos about new features in Windows 8.1. He is showing how to be productive on Windows 8.1 and how to take advantage of key shortcuts.

By the way: Happy New Year 2014!

Happy New Year 2014


Symbolic Links in Windows

Since Windows Vista we have possibility to create symbolic links on Windows. Yay!

To do that, we have command mklink in Command Prompt:

C:\Users\jj\Desktop>mklink link_to_some_file.txt c:\Dropbox\some_file.txt
symbolic link created for link_to_some_file.txt <<===>> c:\Dropbox\some_file.txt

Symbolic link is not a shortcut. However, its icon desktop looks the same:

link and shortcut icons in Windows

You can find out whether it is a link or shortcut by looking on the properties (left – link, right – shortcut):

link vs shortcut in Windows

You can also check it from the command prompt:
C:\Users\jj\Desktop>dir
Volume in drive C has no label.
Volume Serial Number is A425-1CEF

Directory of C:\Users\jj\Desktop

11/15/2013 10:36 AM <DIR> .
11/15/2013 10:36 AM <DIR> ..
11/15/2013 10:35 AM <SYMLINK> link_to_some_file.txt
11/15/2013 10:36 AM 921 some_file - Shortcut.lnk
2 File(s) 921 bytes
2 Dir(s) 15,738,155,008 bytes free

OT: Don’t you think dir command is to verbose? Who needs e.g. Volume Serial Number each time during listing directory?

In PowerShell, you need to use following command: cmd /c mklink (precede mklink with cmd /c).

I use it for my PowerShell config file. Original one is in Dropbox and symlink just point to it from MyDocuments directory (where it has to be, to be applied by PowerShell).


Windows PowerShell profile

Windows PowerShell is very powerful tool. It contains many useful commands. One of my favorite features is possibility to use some well-known bash commands such as: ls or pwd, which are missing in Windows Command Prompt. The cool thing is the fact, that PowerShell contains combination of Windows Command Prompt and Bash shell commands. E.g. for copying you can use copy (Windows) and cp (Bash).

You can also have personal configuration file (like .bashrc in Unix) to set some persistent settings. To find out, where it is located use command:

PS C:\> echo $PROFILE
C:\Users\jj09\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

I needed to create directory ‘WindowsPowerShell’ and profile file before adding some custom settings. Additionally, I needed to enable scripts on my system (it is disabled by default).

PS C:\> Set-ExecutionPolicy RemoteSigned

More info about Execution Policies can be found here.

My Microsoft.PowerShell_profile.ps1 file:

set-alias subl "C:\Program Files\Sublime Text 2\sublime_text.exe"
set-alias grep select-string
set-alias ssh New-PSSecureRemoteSession
set-alias sh New-PSRemoteSession
set-alias l ls

There is also ‘Power’ version of PowerShell called ISE (Integrated Scripting Environment). Be aware, that it has different profile file (for me it is: C:\Users\jj09\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1). You can check it with the same command like for standard PowerShell (echo $PROFILE). Here is a list of top 10 killer features, which are in ISE, but not in standard PS (Intellisense is my favorite).

PowerShell-autocomplete

Disadvantage of PowerShell is its loading time. Windows Command prompt loads instantaneously, but PS need ~1 second. It is even worse in case of ISE, which needs ~3 seconds (on my Thinkpad X220: i5/8GB/SSD).

You can add custom configuration to Windows Command Prompt too. To do that you need to run command prompt with some arguments.