Useful PowerShell snippets for Storage Spaces Direct (S2D) operations

30 May

This is a very quirk post to just share some simple PowerShell snippets I have created or found elsewhere which I find very handy when it comes to troubleshooting, setup or operating Storage Spaces Direct (S2D).

1. Get the count of physical disk in each node:
When S2D is enabled in a cluster Get-Physicaldisk returns the physical disk from all cluster nodes. But when you want the disk count of each node the following script can be quite useful:

2. Get the processed and completed GBytes of running Storage Jobs (e.g. Rebuild Jobs):
This one comes from the Jaromir Kaspar and his ws2016lab Project on GitHub, which is btw a very nice  project to build a test lab in a highly automated way. So all credit goes to him for this script.
It shows you the amount of GBytes the running storage jobs have already processed and how much must still to be processed until the jobs are finished.

(original source: ws2016lab project)

Speaking at Experts Live Switzerland in Bern

9 Apr

On 3rd of May the one day country event of the Experts Live conference series will take place at the “Workspace Welle 7” in Bern and I am really looking forward to join this event as a speaker. Together with my colleague and fellow MVP Michael Rueefli  I will have a talk about Infrastructure as Code and DevOps. 

We will show you what the buzzword Infrastructure as Code actually means and how Infrastructure as Code can be used in the real world in real projects and environments. Furthermore we will give you some guidelines how you can leverage DevOps principals for platform and infrastructure automation so you, as an IT Pro, will be ready for the new agile and and fast pacing future of IT.

If you never heard about the Experts Live Switzerland Event here some more details why you should join us on May 3rd in Bern 🙂

  • One day Conference
  • Completely held in German
  • 17 Sesssions
  • 3 parallel Tracks
  • Top Community Speakers
  • Max. 180 attendees
  • Exhibitors area for partner
  • Initiated and managed by the community
  • modern and easily accessible location
  • Focus on Microsoft Cloud, Datacenter and Workplace topics

Ah! And if you have not already, register you right away. Only a very small amount of tickets are left!

Simple and fast way to ensure a PowerShell script runs always “as Administrator”

22 Jan

Sooner or later when you are writing PowerShell scripts you have the situation where you want to ensure that the Script is running with elevated user rights (aka “run as Administrator”). Often this is the case when the script should make some configurations changes or some Cmdlets, used in the script, works only with elevated user rights.

When you search the web you can find several solutions with functions or if statement to check the right of the user under which the script currently run and then abort if he does not have admin rights.
But actually there is a simple, builtin, way to ensure the the script runs only in a PowerShell session which was started with “run as Administrator”.
Simply add the following line (with the #) at the top of your script:

When the Script is then started in a normal (not elevated) PowerShell session it fails with the following, very clear, error message:

The script ‘youscriptname.ps1’ cannot be run because it contains a “#requires” statement for running as Administrator. The current Windows PowerShell session is not running as Administrator. Start Windows PowerShell by using the Run as Administrator option, and then try running the script again.

This works with PowerShell 4.0 and later and there also other ‘Requires’ statements which an be used in Script. For example to ensure a specific version of a PowerShell Module is installed.
A full reference an be found on in the online PowerShell Documentation.

Webinar “Azure Automation and PowerShell DSC” (German)

10 Oct

Tomorrow, on Tuesday October 11 2016 at 2pm (CEST) I will do a webinar in German about Azure Automation and PowerShell DSC . I will explain the basic concepts of Azure Automation, Automation Runbook and PowerShell DSC.

A main part of the webinar will be a example scenario to automatically deploy and configure a VM using Azure Automation Runbooks and Azure Automation DSC. I will configure the whole scenario live during the webinar.


When you interested in the scripts, which I am using to configure the scenario, you can get it here.

If you like to attend the webinar  you can still register here for free.