PowerShell – Office 365 – Enable or disable service plan options within each license package while respecting current configuration for each user

Even when using PowerShell, Microsoft doesn't make it simple when it comes to adjusting licensing in bulk and service plan options/apps within. Mainly that is because there is no easy way to keep a current configuration - any license change you apply to a user overwrites their existing setup. To address that letdown I created a script you can find below. I tried to make this script very flexible and user friendly, please see the highlights of the script: the script is interactive - just select all actions; no need to predefine any variables; works with all license packages; allows both enabling and disabling services/apps; respects the currents configuration for each user. This script assumes you are already connected to the right services and have all modules installed. # List License Packages $LicensePackageChoices = @() $i = 0 $LicensePackages = Get-MsolAccountSku ForEach ($LicensePackage in $LicensePackages) { $outObject = "" |…

Continue ReadingPowerShell – Office 365 – Enable or disable service plan options within each license package while respecting current configuration for each user

PowerShell – SharePoint – Move folders between site collections, subsites, and libraries

There are several ways to move data between libraries in SharePoint. One of them is using UI. While this method has become better over the years, it's still slow and buggy at times. Just recently I had an issue where SharePoint UI would not move more than 20 folders, it would time out.  Another method is using PowerShell to do such a task. Out there you can definitely find scripts that would move data; however, you need to provide all prerequisite information and do it correctly. A typo or a library display name vs different internal name would leave you scratching your head for quite some time. If you do use subsites in your site collections, then things become progressively more complicated. To address most of the struggle I decided to create a script that will do it all. The goal was to automate everything where an admin would only…

Continue ReadingPowerShell – SharePoint – Move folders between site collections, subsites, and libraries

Adaptive Cards – edit default approval Adaptive Card

This post will describe what steps to take to adjust a default Approval Adaptive Card. Why would one want to do that? Well, by default it shows some unnecessary information, Requested by First Last Name note is probably the most questionable.  In the example below a Power Automate Flow will be used to post a card into Microsoft Teams. Please note it's easy to break an Approval Adaptive Card when changing its JSON code. Let's create a Flow that creates an approval request, posts an Adaptive Card, and then waits for its result. Make the Flow run - what we really need is the output of it. Copy the code from the Message field as shown below. Go to https://adaptivecards.io/designer/ and paste the previously copied code into the Card Payload Editor. As soon as you change any element in your card using the visual editor, the code in the Card Payload…

Continue ReadingAdaptive Cards – edit default approval Adaptive Card

PowerApps Form – submit multiple forms at once without Patch and extra buttons

Everyone knows that PowerApps Forms are much trickier than their siblings - PowerApps Apps. So when it comes to creating a multi form experience it's not the same for PowerApps Forms. In fact Microsoft PowerApps Team recommends using a Patch function or other workarounds. So officially multi forms for PowerApps Forms are not supported. It's obvious why one would like to use multiple forms over a huge single form - a better user experience and a natural feel. So it is doable and the benefits of using it the way I described below are: No extra buttons. While a custom button can compliment your form and expand its functionality, you still have standard buttons you cannot hide. All columns can stay required on a SharePoint level. The forms will react to those required fields as needed. No Patch function. Don't get me wrong, the Patch function is very useful but…

Continue ReadingPowerApps Form – submit multiple forms at once without Patch and extra buttons

Microsoft Flow – parse email and extract information

If you have a 3rd party system that sends standardized notifications and you would like to automatically process those notifications, then this Flow can be helpful. The flow below parses a predefined email, extracts information for you to take further actions with it. Those actions can be: saving data into a SharePoint List; forwarding part of an email to another system; removing all formatting and so on. The flow is pretty simple and consists of these steps: 1) Trigger - When a new email arrives. 2) Action - Html to text - convert email body from HTML to plain text. 3) Action - Initialize variable - store a carriage return value in it. Peek code view: { "inputs": { "variables": [ { "name": "CRLF", "type": "String", "value": "\n" } ] } } 4) Action - Compose - split output from #2 into an array. Expression: split( trim( uriComponentToString( replace( uriComponent(…

Continue ReadingMicrosoft Flow – parse email and extract information

PowerShell – script to reset user password in AAD and AD then force sign out from Office 365 services

The only purpose of this script is to act as fast as possible when dealing with a successful phishing attack where one of your users got compromised. You can perform all the steps below one by one using UI but it takes more time which must not be wasted in such a case. So, here are actions the script does: Creates a new random password (you can play with how your temp password should look like). Your user will be forced to change it. Resets a password in the cloud / Office 365. Optionally resets a password in your on-premise AD (if your accounts are synced with Active Directory) Terminates all active Office 365 sessions (Invalidates the refresh tokens issued to applications for a user per Microsoft). In order to reset passwords in AD the script must “Run As” an account that can edit AD. If you are remote, you…

Continue ReadingPowerShell – script to reset user password in AAD and AD then force sign out from Office 365 services

PowerShell – script to show all mailbox rules and disable selected ones

Ever needed to quickly find and disable mail rules in user mailboxes? Look no further as the script below does all of it. It’s a convenience by itself to not go into Exchange Admin Portal, but there might be cases where your user gets hacked, some bad person creates a rule or two. Then you need to disable those quickly. So this script does the following to a specified email: lists all mailbox rules and shows their most important info - its actions, description, and status; then you can select and disable any rule by typing its number until (if desired) all rules are disabled. Don’t forget to replace @contoso.com with your own domain. #---------------------------------------[Functions]--------------------------------------------------- Function List-Rules { param ( [Parameter(Mandatory=$True)]$email ) Begin{} Process{ $collection = @() $i = 0 $rules = Get-InboxRule -Mailbox $email ForEach ($rule in $rules) { $outObject = "" | Select Number,Status,"Rule Name","Applies to emails From","Delete…

Continue ReadingPowerShell – script to show all mailbox rules and disable selected ones

SharePoint Column Formatting – hide Title column and use JSON to show View and Edit buttons in any column

It’s not always convenient to use a default Title column that comes standard with a newly created SharePoint list. PowerApps form can take care of it and add some logic to it but it is still a Single line of text column. To make it even more complicated to remove, that Title column ties to a "view/edit an item" link. If you still want to get rid of it and not lose any functionality you can use a simple JSON code below: { "elmType": "a", "txtContent": "@currentField", "attributes": { "href": "='https://contoso.sharepoint.com/sites/dev/Lists/TestList/DispForm.aspx?ID='+[$ID]" }, "style": { "padding": "10px", "font-weight": "bold" } } However, this method has quite a few downsides: when closing a form, it redirects to a Default view (it is possible to specify which view to go but that might be a lot of hard-coding depending on how many views you have); the link is hard-coded; does not seem to open "modern…

Continue ReadingSharePoint Column Formatting – hide Title column and use JSON to show View and Edit buttons in any column

PowerShell – auxiliary script to populate CustomAttribute10 with a Purged Items FolderID

Originally this script ( New-ComplianceSearch script ) would search through Purged Items. That was the downside of it comparing to a "classic" Search-Mailbox you can find here ( Search-Mailbox script ). So imagine you run the script the 1st time, find target messages, and then delete them - the found results make sense. However, should you run the script the 2nd time with the same search criteria, it would find those already purged messages again. That creates some confusion. So it would be great to exclude Purged Items folders from the search. Now, it is possible to do so on the fly ( https://docs.microsoft.com/en-us/microsoft-365/compliance/use-content-search-for-targeted-collections ) but it is very time consuming and takes about 1-3 seconds for each mailbox which stacks up pretty fast. So I came up with a script to take care of this issue by storing a Purged Items FolderID in a CustomAttribute10 of each mailbox. So…

Continue ReadingPowerShell – auxiliary script to populate CustomAttribute10 with a Purged Items FolderID

PowerShell – New-ComplianceSearch script to go through all mailboxes, find a target message, and remove it

Here is another more advanced script that searches for messages of interest, then optionally exports and purges them. So, what makes this script more advanced? Unlike the other script that uses Search-Mailbox ( https://365basics.com/powershell-search-mailbox-script-to-go-through-all-mailboxes-find-a-target-message-and-remove-it/ ) this script below is based on New-ComplianceSearch cmdlet: Pros: Super fast, multi-threaded, takes about 1-2 minutes on average to complete the whole task. As Microsoft is trying to depreciate Search-Mailbox, they put more effort into New-ComplianceSearch, so we can expect new functionality to come in the future. Can create an export file that can be downloaded and investigated. Cons: Always searches through all folders including Purged Items which might create some confusion when showing results (if running the same search again) - see UPDATE 9/30/2019 Cannot copy messages to another mailbox for you to investigate. Of course there are quite a few scripts out there that use New-ComplianceSearch, everyone has their own approach. So let…

Continue ReadingPowerShell – New-ComplianceSearch script to go through all mailboxes, find a target message, and remove it