What if Optimize-StoragePool doesn’t work with the “-WhatIf” switch?

Just recently I was running optimization job on S2D pool, so lead by curiosity I wanted to start it with the “-whatif” witch, like this:

$UniqueId = (Get-StoragePool | Where {$_.IsPrimordial -eq $false}).UniqueId
Optimize-StoragePool -UniqueId $UniqueId -whatif

I have found it on this wonderful blog:

And guess what? It started to do the job…

So be aware about that once “testing” the Optimize-StoragePool cmdlet.


Exchange – two ways to create new role assignments.

Forgotten this recently and got caught spending some time investigating.

Boys and girls, remember one thing – if you create role assignments like this:

New-ManagementRoleAssignment -Name "ASSIGNMENT NAME" -Role "ApplicationImpersonation" -CustomRecipientWriteScope "IMPERSONATION USERS" -SecurityGroup "IMPERSONATION ADMINS"

where “IMPERSONATION ADMINS” is your a security group created by you – this role assignment will NOT be visible in your “admin roles” area in Exchange Console:


Instead, you need firstly create a Role Group and assign role to it, for instance


New-ManagementRoleAssignment -Name "ASSIGNMENT NAME" -Role "ApplicationImpersonation" -CustomRecipientWriteScope "IMPERSONATION USERS" -SecurityGroup "ROLE GROUP IMPERSONATION ADMINS"

Only assigning a role to a role group allows it to appear in the admin roles area.

Remember about that!



How to properly reboot machine with PowerShell.

Just today my wonderful colleague showed me a great way to restart machine and at the same time – test if it has came up and is operational (basically if PowerShell responds remotely).

Restart-Computer -ComputerName <COMPUTERNAME> -Wait -Protocol wsman -force

Use -force to forcely logoff any active sessions (savage!!!!)

After performing restart in above way, console waits and will not go further, unless PS on the remote machine responds!



Isn’t that cool!?

Second Polish PowerShell User Group meeting behind us!

Thank you all for joining us on second PPOSH meeting.

Start of the first presentation.

It was an energetic meeting as we had few new faces and there have been some interesting discussions after the sessions – not only about PowerShell 😉

Continue reading “Second Polish PowerShell User Group meeting behind us!”

Same code – different output. ISE vs PS Console and VSCode.

Hey Guys,

Help needed here… I was just finishing another function for UK Power Cuts (still dirty as pile of dung I know, but works :P) while I noticed something weird.

Scottish and Southern have power cuts info in Javascript generated tables, the thing is, each position might be slightly different / have different fields – for instance one position will not have information about estimated time Engineer will be on place.

Let me show you what I mean on the, picture as we all know it is worth a thousand words:ScottishAndSouthern.jpg

Continue reading “Same code – different output. ISE vs PS Console and VSCode.”

Search Power Cuts In The UK Using PowerShell!


So recently I’ve met this problem that we lost power in one of our offices in the UK, however we didn’t know the reason – might have been UPS malfunction, some bypass troubles, etc. Finally we identified there was a power cut by calling local users.

To make similar problem identification more swift and robust (basically to include that in our IT infrastructure monitoring solution) I’m preparing (still under development ^^) a module that might help in identification if there is a power cut for certain post code.

Continue reading “Search Power Cuts In The UK Using PowerShell!”

PowerShell script for Exchange mailbox item (email, meeting, contacts, etc.) removal.

You might have a situation when someone – it might have even been you – send or receive an email that shouldn’t be sent or received.

It might have been a SPAM sent to your organization or an email that supposed to be send to your colleague but was send to a bunch of other people and had naked ladies in the attachment.

After sending such email reaction chain is as follows:

First you noticed that you have might clicked “Send” button, maybe you clicked CTRL + Enter combination, but you still not sure…


Continue reading “PowerShell script for Exchange mailbox item (email, meeting, contacts, etc.) removal.”