Make the Calendar in Microsoft Teams use the same keyboard shortcut as Outlook

I use keyboard shortcuts a lot and in outlook I am used to the Ctrl+1/2/3/4 to go between mail, calendar, contacts, etc. In teams I found myself using Ctrl + 2 to go to the calendar which actually brings you to the Chat tab. I know I could use Ctrl + 4 but you know muscle memory…

Then I found out you can reorder all the tabs on the left, so not I have Chat at the top just like my mail Ctrl + 1 followed by Calendar which means it is Ctrl + 2 which is now very similar to Outlook!

This may or may not help someone but I found it handy.

Getting Night Light to work with a docking station in Windows 10

This comes from How to enable Night Light feature on DisplayLink devices in Windows 10.

I have a Targus docking station and luckily it used DisplayLink, the key does not exist with the Targus drivers installed so…

  1. Go to https://www.displaylink.com/downloads/windows and download the DisplayLink drivers.
  2. Install them.
  3. Start RegEdit
  4. Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\DisplayLink\Core
  5. Create new String value with name EnableGammaRamp and set the data to be: true
  6. Unplug and plug your DisplayLink device
  7. Enable Night light in Windows

All your monitors should now be at the same gamma settings.

Work at home and being a team

Now that we are dealing with COVID-19, a lot of companies are getting their employees to work remotely. For some this will be great and for other who crave social interaction not so great. For me the key thing is making sure that my team feels like a team still.

Keeping the routine going is pretty important. For yourself and your team. There are lots of great posts about this so I will just list the key points.

  • Get up and get ready for work. Do not sit around in your pajamas.
  • Have a work space separate to your daily living. If you have a spare bedroom put a table in there. I even heard of a person using a large walk in closet as a impromptu office.
  • Eat well. If you have lots of snack foods in the kitchen it is easy to graze all day. If it is Girl Scout cookie season lock then somewhere and throw the key away.
  • Stop working at lunch and walk or sit with the family to eat. If there is no one in the house get out for some fresh air or watch a short show or video. Like the list of Ted talks you have been putting off watching for a year because you do not have time.
  • Set working hours and stop for the day. Walking out of your temporary office and close the door or put the laptop away or put a sheet over your monitors.

When it comes to your team there are a few things you can do.

Firstly make sure you keep the same rhythm where possible, if you have a normal morning meeting make it a online meeting. I use Microsoft teams and it is great as it integrates well with the rest of office and makes meeting management and scheduling easy. Microsoft has made teams free during the outbreak to help businesses and educational institutions. Even individuals can get it if they want.

State working hours for the team, if people have to work from home and schools are closed they may have to deal with child care or taking children to different locations during the day. I usually start with core hours of 10am until 4pm, during this time the team should be availble to talk, take a cll or be able to make a meeting. No meetings should be scheduled outside of this window.

If you need to talk about a topic do not book a meeting! Make a chat in teams with the right people and renamed the chat to be the subject of the dicussion. This allows:

  • Ability to add people later with them being able to see the full chat history if needed.
  • People to respond when they are at their computer so they can fit the work around the day.
  • Ability to use a shared whiteboard.

Get them to put a meeting in the calendar for lunch so they have a dedicated block to step away from the computer.

Set up a weekly or even better daily 15-30 minute meeting with a teams channel for social interaction. You can even theme it so one day can be what is the best meme, another is photos of their working environment. On Fridays it can be cocktails hour and make the event at the end of the day.

Any other suggestions if you are managing a team remotely?

Auto Update Git Aliases

Because I am lazy I wrote a script so I can update all my machines from the one location which is the gist below. This works in powershell core. Again this is mostly for me but feel free to use as needed.

Update your $profile to have th following environment variable set. This will allows the wid and pid aliases to work correctly.

$env:GIT_PERSONAL_EMAIL = "personal@personal.com"
$env:GIT_PERSONAL_USERNAME = "myname"
$env:GIT_WORK_EMAIL = "work@work.com"
$env:GIT_WORK_USERNAME = "myworknameoralias"

Script to update aliases. Add to your profile or a function in your profile that you can call when you want.

$gitConfig = Get-Content $env:userprofile\.gitconfig
$hasAliasInclude = $false
$aliasIncFile = "$env:userprofile\alias.inc"

# Update inc. 
if((Test-Path $aliasIncFile)) {
    Remove-Item -Path $aliasIncFile -Force | Out-Null
}
Write-Host "Updating the Alias Include"
Invoke-WebRequest -UseBasicParsing -Uri "https://gist.githubusercontent.com/sytone/03d9b90abb936830253f60f7f40a1a06/raw/.gitconfig" -OutFile $aliasIncFile
(Get-Content $aliasIncFile) | Foreach-Object { $_ -replace "ENTERPERSONALEMAILADDRESS", $env:GIT_PERSONAL_EMAIL } | Set-Content $aliasIncFile
(Get-Content $aliasIncFile) | Foreach-Object { $_ -replace "ENTERPERSONALUSERNAME", $env:GIT_PERSONAL_USERNAME } | Set-Content $aliasIncFile
(Get-Content $aliasIncFile) | Foreach-Object { $_ -replace "ENTERWORKEMAILADDRESS", $env:GIT_WORK_EMAIL } | Set-Content $aliasIncFile
(Get-Content $aliasIncFile) | Foreach-Object { $_ -replace "ENTERWORKUSERNAME", $env:GIT_WORK_USERNAME } | Set-Content $aliasIncFile

for ($i = 0; $i -lt $gitConfig.Count; $i++) {
    if ($gitConfig[$i].Contains("[include]") -and $gitConfig[$i+1].Contains("path = alias.inc")) {
        Write-Host "Found include, skipping add."
        $hasAliasInclude = $true
    }
}

if (!$hasAliasInclude) {
    Write-Host "Missing include, adding."
    $includeStatement = @"
[include]
`tpath = alias.inc
"@
    $includeStatement | Add-Content $env:userprofile\.gitconfig
}

Using PowerShell core in Visual Studio Code on windows

This is more for me than anyone else. If you want to move to PowerShell core in Visual Studio Code then do the following.

  1. Press CTRL + , to open settings.

  2. Enter terminal in the search box.

  3. Scroll down to Terminal > Integrated > Shell: Windows

  4. Click on ‘Edit in settings.json’ and add the following.

    "terminal.integrated.automationShell.windows": "c:/tools/pwsh/pwsh.exe",
    "terminal.integrated.shell.windows": "c:/tools/pwsh/pwsh.exe"

Now when the terminal is opened it will be using PowerShell 6 / Core.

To install the PowerShell Core / 6 got to https://github.com/powershell/powershell

Using git aliases

I work with git for home and work project, I recently found you can use alias across all platforms due to the way it runs on windows. So all these aliases will work happily on git for windows and hopefully will make you work day more streamlined.

Some are from sites I have found and other I have created myself.

To access the global git configuration run the following command and then add this to the bottom if you do not have a alias section already. This command will use your default editor.

git config --global -e

These are all the aliases, just cut and paste into the configuration.

[alias]
  co = checkout
  ec = config --global -e
  ecl = config -e
  up = !git pull --rebase --prune $@ && git submodule update --init --recursive
  cob = checkout -b

  # Create a new branch with static naming and switch to it.
  cobm = "!f() { git checkout -b users/$USERNAME/$1; git push --set-upstream origin users/$USERNAME/$1; }; f"

  cm = !git add -A && git commit -m
  cmp = "!f() { msg=${1-Lazy commit and push}; echo \"Commiting with message: $msg\"; git add -A; git commit -m \"$msg\"; git push; }; f"
  save = !git add -A && git commit -m 'SAVEPOINT'
  wip = commit -am "WIP"
  undo = reset HEAD~1 --mixed
  amend = commit -a --amend

  # Want to start again, this will add you current changes and then reset the HEAD. You can always get back the files you abandoned.
  wipe = !git add -A && git commit -qm 'WIPE SAVEPOINT' && git reset HEAD~1 --hard

  # To get the WIPE changes back again.
  unwipe = "f() { SavePoint=$(git reflog --pretty=format:'%h|%s' | grep 'WIPE SAVEPOINT'); IFS='|'; read -ra HASHES <<< $SavePoint; git checkout $HASHES; }; f"

  # This will delete any branches already merged to master to keep you local repo clean.
  bclean = "!f() { git checkout ${1-master} && git branch --merged ${1-master} | grep -v " ${1-master}$" | xargs git branch -d; }; f"

  # Run this after your PR is in to switch back to master and cleanup branches.
  bdone = "!f() { git checkout ${1-master} && git up && git bclean ${1-master}; }; f"

  logg = log --oneline --graph --color --decorate
  pid = !git config user.email 'ENTERPERSONALEMAILADDRESS' && git config user.name 'ENTERPERSONALUSERNAME' && git config user.email && git config user.name
  wid = !git config user.email 'ENTERWORKEMAILADDRESS' && git config user.name 'ENTERWORKUSERNAME' && git config user.email && git config user.name
  whois = "!sh -c 'git log -i -1 --pretty=\"format:%an <%ae>\n\" --author=\"$1\"' -"
  whatis = show -s --pretty='tformat:%h (%s, %ad)' --date=short
  graphviz = "!f() { echo 'digraph git {' ; git log --pretty='format:  %h -> { %p }' \"$@\" | sed 's/[0-9a-f][0-9a-f]*/\"&\"/g' ; echo '}'; }; f"
  aliases = !git config --get-regexp 'alias.*' | cut -c 7- | sed 's/[ ]/ = /'
  lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative    
  open = "!f() { REPO_URL=$(git config remote.origin.url); explorer ${REPO_URL%%.git}; }; f"
  browse = !git open
  churn = !git log --all --find-copies --find-renames --name-only --format='format:' "$@" | sort | grep -v '^$' | uniq -c | sort | awk 'BEGIN { print \"count\tfile\" } {print $1 \"\t\" $2}' | sort -g
  remote-merged = "!f() { for branch in $(git branch -r --merged | grep -v HEAD);    do echo -e $(git show --format=\"%ci %cr %an\" $branch | head -n 1) \\t$branch; done }; f | sort -r"
  remote-merged-me = "!f() { for branch in $(git branch -r --merged | grep -v HEAD); do echo -e $(git show --format=\"%ci %cr %an\" $branch | head -n 1) \\t$branch; done }; f | grep $USERNAME | sort -r"
  remote-merged-query = "!f() { for branch in $(git branch -r --merged | grep -v HEAD | grep -i \"$1\"); do echo -e $(git show --format=\"%ci %cr %an\" $branch | head -n 1) \\t$branch; done }; f"
  remote-age = "!f() { for ref in $(git for-each-ref --sort=-committerdate --format=\"%(refname:short)\" refs/remotes); do git log -n1 $ref --pretty=format:'%Cgreen%cr%Creset | %C(yellow)%d%Creset% | %C(bold cyan)%an%Creset%n'; done }; f"

Filling your calendar for the week, increase productivity! Mileage may vary

I like to ensure my calendar gets filled for the next week, this way I know what is happening and it is hard to book a last minute meeting to surprise me. I guess this is a productivity hack. If you book more than a week out then you can take whatever time you want that is open.

Ideally no one books last minute but they do and it is really annoying to deal with. Just call me!!

Anyway here is a PowerShell script to block out your calendar for the next week using the Outlook COM API locally. I’m sure I can do the same with rest but I am not up for doing OAuth in PowerShell today. The code is not clean and tidy and has issues which I could fix if I could be bothered but it meets MVP. Feel free to suggest updates.

New PowerShell module for Home Assistant

So after making the PowerShell script for Home Assistant I decided to spend a hour and pull it together to be a full module and push it up to GitHub. This is now in place and support just turning a switch entity on and off.

Installation

Install-Module -Name PoshHomeAssistant -Scope CurrentUser

Usage

Before you can use it set the configuration, this can be done with the following command, set the key and url to match your environment.

Set-HomeAssistantConfiguration -AccessKey "YourAccessKey" -BaseUrl "http://192.168.0.1:8123"

To turn a light on and off run the following commands, they will return the state of the related entities for you to use if needed.

Set-HomeAssistantSwitchState -Entity "switch.2studylamp" -State On
Set-HomeAssistantSwitchState -Entity "switch.2studylamp" -State Off

Related Article: Getting PowerShell to work with Home Assistant

Getting PowerShell to work with Home Assistant

I wanted to turn on and off my office lamp from my desktop, sure I can use a switch but it is hooked up to Home Assistant so lets make it automatic! The main scenario was to toggle it at 10pm so when I get distracted it will let me know the time. You can use this for just about anything and at some point I will add more functions. Here is the snippet for now. You can set the values of global in your profile or in the launching script. As long as they are set this will work.

Script

Just past this into a file and run after updating the password, URL for your Home Assistant installation and then the entity id.

function Set-HomeAssistantAccess($AccessKey, $BaseUrl) {
    $Global:HomeAssistantAccessKey = $AccessKey
    $Global:HomeAssistantBaseUrl = $BaseUrl
    $Global:HomeAssistantHeader = @{ "x-ha-access" = $AccessKey; "Content-Type" = "application/json"}
}

function Set-HomeAssistantSwitchState {
    param (
        [String] $Entity,
        [ValidateNotNullOrEmpty()]
        [ValidateSet('On', 'Off')]
        [String] $State
    )

    $body = @{entity_id = $Entity} | ConvertTo-Json
    switch ($State) {
        "On" { Invoke-RestMethod -Method POST -Uri "$Global:HomeAssistantBaseUrl/services/switch/turn_on" -Headers $Global:HomeAssistantHeader -Body $body }
        "Off" { Invoke-RestMethod -Method POST -Uri "$Global:HomeAssistantBaseUrl/services/switch/turn_off" -Headers $Global:HomeAssistantHeader -Body $body }
        Default {}
    }
}

Set-HomeAssistantAccess -AccessKey "youraccesskey" -BaseUrl "https://yourdomainorip/api"
Set-HomeAssistantSwitchState -Entity "switch.yourlightentityid" -State On
Set-HomeAssistantSwitchState -Entity "switch.yourlightentityid" -State Off

Home Assistant

Loading message from the API: ...