Tag Archives: Module

Configure Storage Sense using PowerShell

Recently the Storage Sense functionality has been added to Windows. Unfortunately there are no PowerShell commands available to manage this so I decided to write this function to be able to manage the different settings that are available in regards to Storage Sense.

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

By clicking: Change how we free up space, the following options become available:

So in order to configure this using PowerShell I have created the Set-StorageSense function with the following parameters:

  • EnableStorageSense
  • DisableStorageSense
  • RemoveAppFiles
  • ClearRecycleBin

So if you would like to disable this functionality and not have Windows automatically clear out temporarily and otherwise obsolete files you can run the following command:

1
Set-StorageSense -DisableStorageSense

Alternatively the other options can also be configured, the following command Enables Storage Sense and configures all cleanup options to true while displaying verbose output:

1
2
Set-StorageSense -EnableStorageSense -RemoveAppFiles $true`
-ClearRecycleBin $true -Verbose

This would of course not be complete without being able to query this data as well, which is possible using the Get-StorageSense function:

Although I looked into manually triggering the Clean Up job, this is something that did not seem possible, I used Sysinternals Procmon to determine which command is associated with that. But even when running this as the System account it did not appear to clean anything. I will provide the execution in case it is of value for anyone else:

c:\windows\system32\svchost.exe -k localsystemnetworkrestricted -s StorSvc

Let me know if PowerShell functions like these are useful to you and if it works as expected. Do note that this functionality is only available in recent builds of Windows 10.

Links in this Article
GitHub – Get-StorageSense
GitHub – Set-StorageSense
GitHub – CustomizeWindows10 Module
PowerShellGallery – CustomizeWindows10 Module

 

Share

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

 

Share

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
Share

Fix DirectAccess Windows Internal Database – PowerShell Module

I ran into an odd problem with one of the Windows systems at a customer that was running with a very high CPU load. The system is running Windows Server 2012R2 with the DirectAccess role enabled. Upon further investigation it seemed that the SQL Server process that is running the Windows Internal Database for DirectAccess was to blame here:

DADBBefore

I did some digging around on the web and found this blog post by Richard Hicks that described the exact problem I was experiencing on the DirectAccess servers:
DirectAccess SQL Server High CPU Usage – Richard Hicks/

In his blog post Richard used the GUI to manually create an additional index to reduce the CPU load on the DirectAccess server. Because I was having this issue on multiple servers I decided to create a PowerShell module based on his instructions. I have finalized the PowerShell module and made it publicly available: FixDaDatabase

The module comes with three cmdlets:

  • Get-DaDatabaseIndexStatus
  • Add-DaDatabaseIndex
  • Remove-DaDatabaseIndex

To get started with the module either download the module from GitHub, the TechNet Script Gallery or the PowerShell Gallery. In order to install the module directly from the PowerShell gallery run the following command:

1
Install-Module -Name FixDaDatabase -Verbose

InstallModule

First we run Get-DaDatabaseIndexStatus to establish if an Index is already present on the system:

1
Get-DaDatabaseIndexStatus

Get-DaDatabaseIndexStatus

Since the additional Index is not available the Add-DaDatabaseIndex cmdlet can be used to create the Index:

1
Add-DaDatabaseIndex

Add-DaDatabaseIndex

To verify the results of this cmdlet the Get-DaDatabaseIndexStatus cmdlet can be used:

1
Get-DaDatabaseIndexStatus -Verbose

Get-DaDatabaseIndexStatusVerbose

After creating the additional Index the CPU load of the system dropped down significantly within a minute:

DADBAfter

The module is available at the following locations:

If you have any questions or suggestions for this module feel free to leave a comment below or submit a pull request on GitHub.

All the links mentioned in this article are available below:

Links in this Article
PowerShell Gallery – FixDaDatabase
TechNet Script Gallery – FixDaDatabase
GitHub – JaapBrasser – FixDaDatabase
DirectAccess SQL Server High CPU Usage – Richard Hicks
Direct Access: Windows Internal Database (SQL) High CPU Usage – Thomas Vuylsteke


Share