PowerShell Function to Restart a Process

My notebook connects to a Docking Station with access to my receiver with speakerset, 2 screens, power and a KVM switch for my mouse and keyboard. When I lock my laptop, the sounds switches from the receiver to my internal speakers. When I unlock my laptop, the sound switches back but the Spotify application doesn’t play any sound. Closing the application doesn’t solve this problem, because the application will crash and I have to use the Task Manager to force the application to close. I made a PowerShell function that I’ve added to my PowerShell profile.

The Restart-Spotify function looks for any process that ends with “spotify” and stops the process. When all the processes are killed, a new instance of Spotify will be opened and the PowerShell console will close itself.

Even a reinstall of Spotify doesn’t help solving this issue I’m facing for months now. So the above script is a great workaround for me.

How to Clear a TPM 2.0 chip with SCCM and PowerShell

With TPM 1.2, Microsoft was able to clear the TPM during the SCCM Task Sequence without asking for permission to clear the TPM. With TPM 2.0, SCCM is unable to clear and activate the TPM chip during the deployment. The first time you boot your computer, you need to provide a BitLocker Recovery Key, or the tpm.msc console will tell you that the TPM is ready for use, with reduced functionality.

Continue reading

PowerShell Profiles – The structure of your _PSH_BASE.ps1 file

In my previous post PowerShell Profiles – The profile.ps1 file I showed you my profile.ps1 file. In this post, I’ll show you a way to structure your base file, so that you can use it for your functions and aliases. Make sure that you always use max 2 files. 1The first file is your profile.ps1 file and the other file is this _PSH_BASE.ps1 file. If you use like 3 or 4 files, it can take a couple of seconds to load your PowerShell session.

Continue reading

PowerShell Profiles – The profile.ps1 file

Welcome to this blog series about PowerShell profiles. I’m using PowerShell profiles for a couple of months now to make life a lot easier. To start this blog series, I would like to show you my Profile.ps1 file. It’s located in “C:\Users\<Your username>\Documents\WindowsPowerShell”. Because I use my PowerShell profiles at multiple locations such as my work notebook, home computer and sometimes at projects, I need to make sure that my PowerShell script home is always right so that the rest of the PowerShell profile is able to load successfully. That’s why I have these commands at the beginning of my profile:

Continue reading

SCCM 2012 R2 SP1 – Make Windows 8.1 drivers supported on Windows 10 with PowerShell

I had an issue within my lab with deploying Windows 8.1 drivers to Windows 10 with SCCM 2012 R2 SP1. It isn’t possible to make all Windows 8.1 drivers compatible with Windows 10 within the SCCM 2012 R2 SP1 console with just one click. Because I was running within a lab environment and I only had 2 driver packages for Windows 8.1 x64, I was able to make the drivers available for deployment to all platforms. You can do this with the magic of PowerShell:

Continue reading

Azure – Deploy and automatically domain join a VM with Azure Automation Runbooks

I was looking for a way to deploy and automatically domain join a VM in Azure. The solution was quite simple: Azure Automation. I found the blog post of DexterPOSH very useful, but the script doesn’t work for me. Follow the steps on his blog and use this script below. I’ll update this post if I find some improvements. Don’t forget to update the domain in the Add-Computer part.

Continue reading

Azure – Automatically deploy a VM in Azure (Runbook)

I was looking for a way to automatically deploy a VM in Azure. The solution was quite simple: Azure Automation. I found the blog post of DexterPOSH very useful, but the script doesn’t work for me. Follow the steps on his blog and use this script below. I’ll update this post if I find some improvements.

Continue reading