The easiest way to work with the Microsoft Graph PowerShell SDK

When you are new to RESTful APIs and want to start with Microsoft Graph to automate tasks in your Endpoint Manager tenant all the stuff about app registrations, access tokens, pagination and request headers can be quite confusing. In this post I want to show you a quick tip to kickstart your Microsoft Graph API experience. Requirements Cloud admin account with Intune Administrator role assigned Ability to install Modules from the PowerShell gallery JWT Just because you can’t see it… doesn’t mean it isn’t there: Due to the naturality of OAuth 2.0 and OpenID connect (these are the protocols involved for authorization and authentication in a cloud environment) we can capture short lived access tokens, also called Json Web Tokens (JWTs) directly from a browser. Tokens are usually valid between 50 and 60 minutes - just what we need to get some hands on with Microsoft Graph API and MEM automation. ...

September 9, 2022 · 2 min · 398 words · Nicola Suter

Intune app protection policy report

App protection (also called MAM) policies have been around for a couple of years within MEM and I already used them in various projects to protect company data on unmanaged iOS and Android devices. One of the drawbacks with this approach is that we do not have full visibility about the usage and I tried to shed some light about this with a PowerShel reporting script that pulls data from the Microsoft Graph API. ...

December 13, 2021 · 1 min · 207 words · Nicola Suter

Have you considered TPM key attestation?

Device and user-based certificates are commonly used for secure authentication for services like: MECM in HTTPS mode, Always On VPN, 802.1x for (wireless) LAN and so on. Mostly these certificates are deployed from an internal PKI and the certificate templates are somewhat outdated because everybody is afraid of touching these settings. As with any type of credentials - credential theft is also applicable for certificates and the corresponding private keys. So let’s dive in and learn the risk and how to reduce the attack surface. ...

August 28, 2021 · 4 min · 840 words · Nicola Suter

Automatically sign your PowerShell scripts with GitHub actions

Based on one of my older posts about PowerShell script signing with Azure DevOps I recently implemented a PowerShell script signing workflow with GitHub actions I wanted to share with the community. Prerequisites For this post the following prerequisites are required: Code signing certificate in PFX format GitHub account Add variables to GitHub actions Because GitHub variables can only be of string content we need to get the contents of the pfx file as base64 encoded string: ...

July 9, 2021 · 2 min · 236 words · Nicola Suter

Securely sending emails from PowerShell scripts with modern authentication enforced

The Send-MailMessage cmdlet has been around for a couple of years and is mostly used to send email messages from PowerShell. But with the deprecation and security flaws of legacy authentication it’s time for a better option which actually supports modern authentication. For this purpose we can use the Microsoft Graph API and the Microsoft Graph PowerShell SDK. The best thing is that this solution works without any service account and does not need any exclusions from conditional access. ...

March 19, 2021 · 3 min · 521 words · Nicola Suter

Dealing with Intune OMA-URI encoding and applocker rules

While fine-tuning and adjusting applocker policies for co-managed Windows 10 clients I got really annoyed by special characters commonly used in the German/Swiss language. The Intune portal seemed to use different encoding and didn’t allow me to just copy/paste the currently deployed policy and extend it with a new rule. I needed to request the original file that was uploaded to the tenant in order to adjust the rule. Instead of just accepting this I decided that it is time for an easier approach which I will share with you. ...

February 16, 2021 · 3 min · 477 words · Nicola Suter

Microsoft Graph Access Token Acquisition with PowerShell explained in depth

When working with the Microsoft Graph API or introducing the API to colleagues I often get asked about the steps required to obtain an access token for the API with PowerShell. Out in the wild, I’ve spotted many different ways and lots of implementations still relying on the ADAL (Active Directory Authentication Library) despite the fact that this client library is superseded by MSAL (Microsoft Authentication Library). So let’s talk about acquiring access token “in stile” with the most simple method available. ...

January 4, 2021 · 7 min · 1340 words · Nicola Suter

Android Enterprise Enrollment: Page Not Found

While doing some Android Enterprise enrollment tests for corporate-owned devices with work profiles I stumbled over the following issue after signing-in with the work account: “Page not found”. The solution is fairly simple, just double check that your user does not have the device enrollment manager role assigned, which can be found under the device enrollment pane: The docs tell us: If you’re enrolling Android Enterprise personally-owned work profile or corporate-owned work profile devices by using a DEM account, there is a limit of 10 devices that can be enrolled per account. Microsoft Docs ...

December 19, 2020 · 1 min · 167 words · Nicola Suter

Housekeeping for stale MEM profiles

When involved in new projects I often find a bunch of old profiles in the Microsoft Endpoint Management Console. Before going ahead with a new implementation it’s the best time to clean-up all the leftovers from past ramblings. How to identify stale profiles If one or multiple statements are met for a profile it is very likely to be a stale profile: No assignments, assignments to a group without members “Test” included within the profile name or description Last modified points back in time for more than a year No devices reported success/failure status for the given profile type What to do with stale profiles So let’s be brave and delete them. But Intune doesn’t offer any [CTRL] + [Z] or recycle bin possibilities so we might want to have some kind of archive, just in case? ...

December 16, 2020 · 2 min · 311 words · Nicola Suter

Windows Terminal and SSH - the most beautiful SSH client?

I like to have a linux machine for some lab stuff which I can access from multiple machines prefereably over SSH. Because Windows 10 ships with an integrated SSH client and Windows Terminal looks just awesome I wanted to use Windows Terminal to access my linux machine running on Azure over SSH. Today I’d like to show you my setup. Generate a Key Pair ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (C:\Users\NicolaSuter/.ssh/id_rsa): Created directory 'C:\Users\NicolaSuter/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in C:\Users\NicolaSuter/.ssh/id_rsa. Your public key has been saved in C:\Users\NicolaSuter/.ssh/id_rsa.pub. Add SSH config file C:\Users\%USERNAME%\.ssh\config ...

December 16, 2020 · 2 min · 226 words · Nicola Suter