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

PowerShell – SharePoint – Permission report for all lists and libraries within every site collection and subsite

Here is a script that comes very handy when you need to replace some SharePoint groups with other ones. While doing so you definitely want to make sure no one has lost access. So you need to know where each group has been used. To create this script I used Salaudeen Rajack's PnP PowerShell to Export Document Library Permissions in SharePoint Online script posted here (https://www.sharepointdiary.com/2019/02/sharepoint-online-pnp-powershell-to-export-document-library-permissions.html), then did some adjustments to it including converting it to a function. Then added my code to go through each site collection and subsite. What this script does and how it might be beneficial to you: goes through every site collection and subsite, then library and list; has a list of site collections to exclude; does not include Office 365 Group sites; outputs the following data - site/subsite URL, library/list title, user/group name, user/group type, permission level, how it's granted. This script might take…

Continue ReadingPowerShell – SharePoint – Permission report for all lists and libraries within every site collection and subsite

PowerShell – Script to migrate a security group and all its members from AD to AAD

When you decide it's time to migrate your security groups from on-premise AD to the Cloud, you might find it very tedious and prone to mistakes. Of course that is if you have lots of groups to move. The script in this post should come to your aid as it finds the group you would like to migrate, creates a new group in AAD with a name you choose, then it adds all users and nested groups into the newly created group - the same as your AD group had. A few nice things this script also does: checks if the group you are about to migrate exists in AD; makes sure a group you will be creating in AAD doesn't already exist; combines description and notes, then adds them to a newly created group in AAD. Note that for this script to work well all nested groups must be…

Continue ReadingPowerShell – Script to migrate a security group and all its members from AD to AAD

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