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

PowerShell Conference EU 2017. Not just about coding.

5th of May, cloudy afternoon in Hanover city. We are heading towards a car parked on the side road, the driver is waving to us from far away and we respond with the same.

There are three of us, with rather heavy breath, without jokes as usually we get in the car firstly leaving our luggage in the trunk. Faces are smiling, but it is kind of smile that you can interpret more like powerless acceptance of fate… Sitting on the back seat, whilst one side on me was really sad and flooded in despair, the second one was thinking about lovely wife and sweet 1 year old son. Not seeing them just for 4 days was really sad experience as for me they are whole world. So it happened… we were on our way back,  left Hannover, already cutting the highway with KIA for around 20 minutes like a really sharp knife cuts butter. I was looking through the window and hundreds of images were going around my head, my eyes stuck in one point whilst being gently swaying on the German highway. All of a sudden my right hand became a focal point for my vision…

And it took my pupils exactly 1 second to double the size, I stopped my eyes on one point and screamed:


Continue reading “PowerShell Conference EU 2017. Not just about coding.”

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

PowerShell script to auto approve WSUS updates for pilot and standard groups.

Recently there has been a need for me to create script that will cover auto approval work for WSUS.

So the idea was tu approve certain patches to pilot group, and after 2 weeks apply these on standard target group and do another pilot group approval for latest time span.

Important! WSUS target groups need to have “Standard” and “Pilot” in their names.

Lines of code that are worth mentioning:

## 64th LINE
## Specify time span between pilot and standard approvals, below is 14 days
$Next_Approval_Date_Raw = (Get-Date).AddDays(14)
## 106 - 108 LINE
## Specify the report file name and path
$CSVFileName = $range+"UpdateTimes.csv"
$CSVPath = 'c:\'
$CSVFile = "$CSVPath$CSVFileName"

So after specifying what period we like we just need to specify the file name and path and we are ready to go!

If we would like to show it on diagram it would look like:


Of course we may add many things to it’s functionality and this is just the very early version of the script. Worth adding might be – and probably will be added in future – a list of updates that were approved to particular target group – it s already there in “verbose” mode, adding possibility to choose the target groups by name other than “Server” or “Workstation”.

Script can be found on TechNet and GitHub.

Exchange mailbox/folders permissions – dependency graph between users.

Following solution uses GraphViz application to visualize mailboxpermissions dependencies in the company.

Some time ago I published a scripts for reading mailbox permissions:

and mailbox folder permissions:

If some of you are wondering what GraphViz is, a quick look on google graphics and phrase “graphviz”, gives us an idea of how gorgeous graphs it can create:


All the GraphViz needs is to have properly formatted input file – that’s it!


The need of having such script showed up as one time I was standing in front of migrating users to Exchange Online. I started to wonder how shall I visualize in a simply way, who need to be migrated together…


It was not an easy task, going though a excel/csv file, or even creating lists were not satisfying for me, so I started to think about it more, even during meals…


And then I found GraphViz:

It was looking really good! So now just a matter of quick reading about it checking if it will apply…


…reviewing the idea…


…some calculations…


And after all that research the idea became clear…


As I mentioned at the beginning, input file can be done with one of the mailbox permissions / mailbox folder permissions reading scripts – links provided on the top (you might need to change delimiters a little bit as I guess in these files are “;” but go for adventure and modify something :))

The proper input should look like:


So it has columns named “Mailbox”, “User” and “AccessRights”

And now the script. In organization I was building script for – it appeared that we have so many permissions I almost shat brikcs when I saw the actual output (graph)…

Just take a look by yourself, here is just a very small piece of graph when I was checking dependencies of just one mailbox – mine:



Let’s go closer:



Imagine now that whole dependency graph contained like 10 more same chunks/pieces, 10 more, 10 fuck*ng times!

Well, I needed somehow to…


So the idea of migrating people together in chunks fell down and broke into pieces :] but at least we have that nice script.

  1. First thing is to get GraphViz application and install it:

Here you can find it:

After installation all you need to to read your mailbox permissions – you can choose to read it with scripts from links given at the beginning of that article.

     2. Next thing, is to set up 3 variables:


$GraphImageFile = “GraphImageFile.png” -> this is the name/path of your output file – actual graph

$GraphGraphVizFile = “GraphVizFile.gv” -> this is the name/path of the input file that will be passed to GraphViz to visualize your data, it will look similar to this one:


$CSVPermissionsFile = “Permissions.csv” –> and finally this is the input file for the script – so output from your script that reads permissions from mailboxes

    3. Having CSV we can start reading permissions, so here are some examples.

After running below:

.\PermissionMatrixGraphBuilder.ps1 -users “Pawel Jarosz”, “Wladek Ksiegowicz”


We will get:


Users mentioned in “Users” array will be marked on blue, nice arrows will show direction of permissions 🙂

After running:

.\PermissionMatrixGraphBuilder.ps1 -users “Pawel Jarosz”, “Wladek Ksiegowicz” -SingleUser $true


We will get:


And finally after running same but with “level” set to 1 we will get:

.\PermissionMatrixGraphBuilder.ps1 -users “Pawel Jarosz”, “Wladek Ksiegowicz” -Level 1


That will runthough the whole file ONLY ONE TIME, and what we will get would be something like:


So summing up – for me script does a good job when it comes to visualize data that would be actually really hard to see from a excel file.

It is just an easy script, please note that you can add here features like:

  • adding description to each “connection” saying to which folder permissions are given
  • reading mailboxes sizes and adding them to the graph so it can ease planing of migration of certain groups of people
  • remember – possibilities are endless:




Script can be found on TechNet and GitHub.