Windows 10 – Start Windows applications from Bash

Working with Bash on Windows, I can say that it significantly simplified the way I can work cross-platform. It has allowed me to use native Linux tools, when working with Linux systems, which is a big step up from using a mix of compiled for Windows Unix tools and GUI applications. Because of this unique functionality Windows 10 has a big lead over any other platform as my day-to-day platform.

For example it is possible to add a new Windows users account directly by using the net.exe tools:

1
net.exe user /add testaccount

Alternatively it is also possible to start Windows PowerShell in Bash to execute a command, for example it becomes possible to use PowerShell to determine which processes are running in the Windows environment and the ps command to determine what is running in Linux:

1
2
powershell.exe -nop -command "Get-Process | Select-Object -First 10"
ps -aux

For me the greatest advantage is the fact that Windows executable files can also be directly called from bash, simplifying the interaction between the different OSes. An example of this is opening explorer in your current working folder in the bash terminal:

1
explorer.exe .

When a path is not accessible for the Windows application, for example anywhere in the Unix file system, a proper error message will be displayed:

1
explorer.exe .

Using this same method it is also possible to add the path to your favorite script editor to the Bash on Windows path allowing them to be directly called from the console. In the following example I will show how to open VSCode directly from Bash:

1
2
3
ls README.md
export PATH=$PATH:/mnt/c/Program\ Files\ \(x86\)/Microsoft\ VS\ Code/
Code.exe README.md

For more information and example of what is possible with the Bash commandline on Windows or I recommend following the Windows Command Line Tools For Developers blog on MSDN.

Configure Windows 10 Blue Light settings with PowerShell

As discussed in the previous post on configuring Lunar Calenders in Windows 10, another interesting feature was also introduced in the 15002 Windows 10 Build: Blue Light Settings. Recently more operating systems have included options for reducing the amount of blue light emitted after sundown. This is easier on your eyes and allows you to fall asleep better at night time.

There are a number of settings that can be configured in the Settings > Display > Blue light settings, settings menu. The settings that can be configured are as follows:

Because automation is a great thing and manually clicking through GUI interfaces is not always optimal I decided to write a PowerShell function to simplify the configuration. For example you could utilize this function to automatically disable the reduced blue light settings when color sensitive work is performed, or lower the amount of blue light emitted as the night progresses. These are some of the actions that the Set-BlueLight function can perform.

To instantly turn of the reduced blue light setting the following code can be run:

1
Set-BlueLight -DisableBlueLight

To enable the reduced color mode and set the color shift to Medium run the following code:

1
Set-BlueLight -EnableBlueLight -ColorTemperature MediumShift

To automatically reduce blue light emitted based on the Day and Night cycle in your geographical location execute this:

1
Set-BlueLight -EnableAutomaticSchedule

The values that are configured by the script are byte arrays in the registry, so it required a bit of reverse engineering to get the values to match the settings in the control panel. The function is currently available on GitHub in my Shared Scripts repository: Set-BlueLight

This function will be added to the CustomizeWindows10 module after I have developed my functional and unit tests to ensure the quality of this function.

For more information about the functions and modules discussed in this article, please refer to the following links:

Links in this Article
GitHub – Set-BlueLight
GitHub – CustomizeWindows10 Module
PowerShellGallery – CustomizeWindows10 Module

 

Enable Lunar Calendar in Windows 10

As I installed the latest build of Windows 10 on my system I read that it was now possible to set the calendar to also display the Lunar Calendar in the calendar overview. Because I like automating stuff I decided to take a look at where this is configured. Note that the steps in this post are based on Windows 10 Build 15002,

It turns out this in configured in the following registry key:
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\CloudStore\Store\Cache\DefaultAccount\$$windows.data.lunarcalendar\Current

Interestingly enough, the store cache seems to contain many of the recently released new functionality in Windows 10. At the moment this seems to be the space to watch if you are looking to automate your settings in Windows, although most values are binary so it might take some work to figure out how to configure this.

After setting this value to the three possible options:

  • Off
  • Lunar Calendar with simplified Chinese characters
  • Lunar Calendar with traditional Chinese characters

Unfortunately this because the Data property is a binary string, so this is not that easy to manipulate. The following values correspond with the settings. I will list both the binary strings as well as their base 64 representation.

Settings Byte Array Base64
Off 2,0,0,0,88,33,207,247,241,107,210,1,0,0,0,0,67,66,1,0,16,2,0 AgAAAFghz/fxa9IBAAAAAENCAQAQAgA=
Simplified 2,0,0,0,148,217,114,130,241,107,210,1,0,0,0,0,67,66,1,0,16,4,0 AgAAAJTZcoLxa9IBAAAAAENCAQAQBAA=
Traditional 2,0,0,0,75,55,152,236,241,107,210,1,0,0,0,0,67,66,1,0,16,6,0 AgAAAEs3mOzxa9IBAAAAAENCAQAQBgA=

To simplify settings these values the Set-AdditionalCalendar function that is included in the CustomizeWindows10 module can be used to configured these settings:

To install this module and configure these settings run the following code:

1
2
Install-Module -Name CustomizeWindows10
Set-AdditionalCalendar -Simplified

For more information about the functions and modules discussed in this article, please refer to the following links:

Links in this Article
PowerShellGallery – CustomizeWindows10 Module
GitHub – CustomizeWindows10 Module
GitHub – Set-AdditionalCalendar

MS Fest Prague 2016 – Short Recap

msfest2016

Last weekend I had the pleasure of being invited to speak at MS Fest in Prague. This was the second year in a row for me that I was speaking at this event and it was once again great to attend and to have the opportunity to meet with people from the other side of Europe.

During the conference I did talked about PowerShell security in which I discussed the different kinds of logging that are available in PowerShell and how they can be utilized to find out what is happening on your system. Furthermore we went into Ransomware, what it is, how it operators and what we can do about it.

My slides and code are, as always, available on my GitHub account:

GitHub – Jaap Brasser – Events – MS Fest Praha

To give you an impression of the event I have included some photos taken during MS Fest:

 

9th DuPSUG Meeting – Ninth time is the charm

The 9th Dutch PowerShell User Group meeting, almost exactly four years after our very first meeting. First of all I would like to thank everyone involved, speakers, IPsoft and our attendees for making this event into a success. We announced this event just 6 days before it was actually held and we were at full capacity within two days. A great show of community involvement which was definitely present during the evening.

During the event we had the following  three speakers and sessions:

Speaker Session
Aleksandar Nikolić Just Enough Administration (JEA), a New Solution for Delegated Administration
Flynn Bundy Getting started with Windows Server Containers
Jaap Brasser Read the Friendly PowerShell Logs

The event was hosted and generously sponsored by IPsoft and the following photos will give you an impression of the event:

We have also created a separate repository on the DuPSUG GitHub account which has all available presentations:

9TH DUPSUG MEETING

During the evening Thierry Cailleau once provided us with live reports of the content being presented including notes and links in our Slack channel, dupsug.slack.com. Feel free to join us there to catch up on the details of the evening.

We hope to see you again in the next year as we have many more events planned in 2017!

PowerShell Conference Asia 2016 wrap-up

Last weekend we wrapped up the PowerShell Conference Asia 2016 in Singapore and it was a great event. I had the opportunity to speak at the event and present a number of sessions. This year we had a healthy mix of PowerShell, DevOps and everything else. The crowd was very engaging, so if you attended the PSConfAsia 2016: “Thank you for being a great crowd!”.

I would like to give a big shout-out to Milton Goh, Matthew Hitchcock, Sebastian Szumigalski, Ravikanth Chaganti and Benjamin Hodge for putting this event together with the support of the sponsors of the event. It was a great opportunity for myself to interact with the PowerShell community in Asia and I thoroughly enjoyed it.

Here are some picture to give you an impression of the event:

I presented and/or recording the following sessions for the conference:

Furthermore I was asked to co-host the Arrested Devops Podcast, which was a new and fun experience for me.

For more information here are the links to the PowerShell Conference Asia website, my GitHub repo and to the Twitter hashtag:

PowerShell Conference Asia 2016
Slide decks and code
PowerShell Conference Asia
#PSConfAsia

Renewed as Microsoft MVP

Last Saturday I received an email from Microsoft that I have been renewed as a Cloud and Datacenter MVP. This year was my first renewal so obviously I am very happy that my contributions over the past year have been rewarded in this fantastic way.

mvp2016

I would like to thank everyone in the technical communities I have participated and contributed to, as I would not have been able to do this by myself. Through your participation, contributions, feedback and comments I have been able to grow and share my technical expertise.

Over the past year I have joined many more communities and participated in numerous events and I look forward to many more interactions with everyone over the coming year. Feel free to contact me if you would like me to speak at any events you are organizing. My contacts details are listed on my About page, or leave a comment below this post.