New-ComplianceSearch not visible in Exchange Online despite being in “Discovery Management”

So just today I learned new thing, I was missing New-ComplianceSearch cmdlet, I was a bit frustrated because I was in all the relevant groups:

Technet was not mentioning a WORD about one thing, I was able to use compliance cmdlets only after I connected diffrently, so if this is your connection string:

$Session = New-PSSession -ConfigurationName Microsoft.Exchange –ConnectionUri -Credential $Credential -Authentication Basic –AllowRedirection

Change it to:

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri -Credential $Credential -Authentication Basic –AllowRedirection

This should do the trick.



Exchange Online and Microsoft.Exchange.Data.SharingPolicyAction is invalid error on Get-MailboxFolderPermission


Recently we got an issue on Exchagne Online, for one mailbox (yes 1! :)) we were not able to properly read permissions, the error was:

•	WARNING: An unexpected error has occurred and a Watson dump is being generated: Value specified for a parameter of type <span id="mce_SELREST_start" style="overflow:hidden;line-height:0;"></span>Microsoft.Exchange.Data.SharingPolicyAction is invalid<span id="mce_SELREST_end" style="overflow:hidden;line-height:0;"></span>: 0.
•	Parameter name: allowedActions
•	Value specified for a parameter of type Microsoft.Exchange.Data.SharingPolicyAction is invalid: 0.
•	Parameter name: allowedActions
•	    + CategoryInfo          : NotSpecified: (:) [Get-MailboxFolderPermission], EnumOutOfRangeException
•	    + FullyQualifiedErrorId : Microsoft.Exchange.ExchangeSystem.EnumOutOfRangeException,Microsoft.Exchange.Management.StoreTasks.GetMailboxFolderPermission
•	    + PSComputerName        :


After contacting Microsoft they suggested running following command:

Get-SharingPolicy | Set-SharingPolicy -Domains Anonymous:CalendarSharingFreeBusySimple,*:CalendarSharingFreeBusyDetail

After running the above command we were able to properly rad permissions. More details about sharing policies can be found here.


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