I’ve been doing some cleanup of my PowerShell scripts and code samples, removing outdated examples, updating code to latest versions where needed, etc. As part of the process, I’ve uploaded few smaller bits of code as gists over at GitHub, and I will use this article to keep an inventory of sorts. Here’s the list, in no particular order:
This code sample takes a list of users as input, fetches the list of currently assigned licenses for the user and removes them. If a license is assigned as part of the group licensing feature, it will be skipped, as those need to be removed by adjusting the scoping from the Azure AD blade.
This is useful for situations where you don’t want to use Full Access permissions, but grant limited access to (a subset of) all folders within a given mailbox. Basically, a toned down version of my bulk set folder permissions script.
Scenario: Bulk (re)Set calendar permissions
A quick snippet to enumerate all user’s Calendars and set the permissions value for the Default user. Useful in situations where you want to change the default calendar sharing behavior within the organization.
Scenario: Bulk remove email addresses
This is a simple code used to remove all proxy addresses matching a given pattern. It takes care of the primary SMTP address as needed.
Scenario: Get the full error message when submitting HTTP(S) requests
You might have noticed that often times errors returned by Invoke-WebRequest or Invoke-RestMethod are fairly vague on details. The gist above shows how you can use the corresponding .NET method to get the full response stream, which will bring back additional useful details on any http error codes.
Scenario: Block access to MSOnline PowerShell cmdlets via the Graph API
Pretty much as the title says, if you need more info read here.
Scenario: Toggle Azure AD Security defaults via the Graph API
Use this code sample to query and change the configuration of the identitySecurityDefaultsEnforcementPolicy object. More details here.
I’ll keep adding those…