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. https://gist.github.com/jvravensberg/302a3de8dbc92b54812afc408f5c43ec The Restart-Spotify function looks for any process that ends with “spotify” and stops the process. ...

19-06-2016 · 1 min · Jean-Paul van Ravensberg

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. I found a script online that I’ve added to my GitHub to clear the TPM 2.0 chip during the deployment. ...

14-02-2016 · 1 min · Jean-Paul van Ravensberg

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. The 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. ...

30-08-2015 · 3 min · Jean-Paul van Ravensberg

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\\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. ...

30-08-2015 · 2 min · Jean-Paul van Ravensberg

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: ...

23-07-2015 · 1 min · Jean-Paul van Ravensberg

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. To-Do list: - Custom static IP as variable. ...

18-02-2015 · 3 min · Jean-Paul van Ravensberg

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. To-Do list: Custom static IP as variable. Custom domain as variable. workflow Deploy-NonJoined-VM { param( [parameter(Mandatory)] [String] $VMName, [parameter(Mandatory)] [String] $ServiceName = "contoso<Insert name>", [parameter(Mandatory)] [String] $InstanceSize = "Small", [parameter(Mandatory)] [String] $VMImageName = "Specify custom or default image name", [parameter(Mandatory)] [String] $AzureSubscriptionName = "Subscription-1", [parameter(Mandatory)] [String] $StorageAccountName = "contoso", [parameter(Mandatory)] [String] $VMSubnetName = "subnet-1", [parameter(Mandatory)] [String] $VMVnetName = "CORP.contoso.com", [parameter(Mandatory)] [String] $VMAffinityGroup = "West-Europe" ) $verbosepreference = 'continue' #Change this to your needs $DomainJoinAccount = "Domain Join Account" $LocalAccount = "LocalAdmin" $AutomationAccount = "Azure Automation Account" #Get the Credentials to authenticate agains Azure Write-Verbose -Message "Getting the Credentials" $Cred = Get-AutomationPSCredential -Name $AutomationAccount $LocalCred = Get-AutomationPSCredential -Name $LocalAccount $DomainCred = Get-AutomationPSCredential -Name $DomainJoinAccount #Add the Account to the Workflow Write-Verbose -Message "Adding the Azure Automation Account to Authenticate" Add-AzureAccount -Credential $Cred #select the Subscription Write-Verbose -Message "Selecting the $AzureSubscriptionName Subscription" Select-AzureSubscription -SubscriptionName $AzureSubscriptionName #Set the Storage for the Subscrption Write-Verbose -Message "Setting the Storage Account for the Subscription" Set-AzureSubscription -SubscriptionName $AzureSubscriptionName -CurrentStorageAccountName $StorageAccountName #Select the most recent Server 2012 R2 Image Write-Verbose -Message "Getting the Image details" $imagename = Get-AzureVMImage | where-object -filterscript { $_.ImageName -eq $VMImageName } | Sort-Object -Descending -Property PublishedDate | Select-Object -First 1 | select -ExpandProperty ImageName #use the above Image selected to build a new VM and wait for it to Boot $Username = $LocalCred.UserName $Password = $LocalCred.GetNetworkCredential().Password New-AzureQuickVM -Windows -ServiceName $ServiceName -Name $VMName -ImageName $imagename -Password $Password -AdminUsername $Username -SubnetNames $VMSubnetName -VNetName $VMVnetName -InstanceSize $InstanceSize -AffinityGroup $VMAffinityGroup -WaitForBoot Write-Verbose -Message "The VM is created and booted up now.. Deployment done." } #Workflow end

18-02-2015 · 2 min · Jean-Paul van Ravensberg

Windows Storage Spaces - Remove physical disk from storage pool with PowerShell

I have an Intel NUC with 8 GB as media center and Hyper-V host for a test domain controller. I attached 2 physical external disks (1x 2,5" USB 3, 1x 3,5" USB 2) and created a storage pool. A couple of weeks later, I bought a new 2,5" USB 3 disk with 1 TB to replace the older USB 2.0 disk. That disk is a lot quieter than the older one. ...

02-01-2015 · 3 min · Jean-Paul van Ravensberg