Learning and Sharing
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
No Result
View All Result

Get-MsalToken: The Property Authority Cannot be Found on this Object

August 24, 2023
in Blog, Microsoft Graph, Powershell
0
ADVERTISEMENT

Table of Contents

The Property Authority Cannot be Found on this Object

In some cases, when we’re trying to connect to Microsoft Graph PowerShell using the below script.

#Generate Access Token to use in the connection string to MSGraph
$AppId = 'fa09463d-8d14-477c-b92b-3b56406b7c3a'
$TenantId = '09655504-399b-41a5-b5c6-fc98a92bc6d1'
$ClientSecret = 'jbe8Q~mGKViQaH3Usv2xhWL2emnqXXu4KxU.ZalE'
 
Import-Module MSAL.PS -Force
$MsalToken = Get-MsalToken `
    -TenantId $TenantId `
    -ClientId $AppId `
    -ClientSecret ($ClientSecret | ConvertTo-SecureString -AsPlainText -Force)
 
#Connect to Graph using access token
Connect-Graph -AccessToken $MsalToken.AccessToken

We got the following error:

The property ‘Authority’ cannot be found on this object. Verify that the property exists.
At C:\Program Files\WindowsPowerShell\Modules\MSAL.PS\4.37.0.0\Get-MsalToken.ps1:338 char:38
+ … TenantId) { [void] $AquireTokenParameters.WithAuthority((‘https://{0} …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], PropertyNotFoundException
+ FullyQualifiedErrorId : PropertyNotFoundStrict

We check the installed version of the Microsoft Graph PowerShell module on our computer. We’re using the v1 of Microsoft PowerShell SDK module.

Recommend: Update the Graph PowerShell SDK to v2.

PS C:\> Get-InstalledModule Microsoft.Graph | FT -AutoSize

Version Name            Repository Description
------- ----            ---------- -----------
1.28.0  Microsoft.Graph PSGallery  Microsoft Graph PowerShell module

We discovered that we get this error if we run any of the following commands before running Get-MSALToken. We’re assuming it’s going to be any Graph modules though.

  • Select-MgProfile -Name “beta”
  • Import-Module Microsoft.Graph.Users
  • Import-Module Microsoft.Graph.Identity.Signins
  • Import-Module Microsoft.Graph.Authentication

The solution to fix it is quite simple, you just need to add this parameter into the script as follows:

#Generate Access Token to use in the connection string to MSGraph
$AppId = 'fa09463d-8d14-477c-b92b-3b56406b7c3a'
$TenantId = '09655504-399b-41a5-b5c6-fc98a92bc6d1'
$ClientSecret = 'jbe8Q~mGKViQaH3Usv2xhWL2emnqXXu4KxU.ZalE'
 
Import-Module MSAL.PS -Force
$MsalToken = Get-MsalToken `
    -TenantId $TenantId `
    -ClientId $AppId `
    -ClientSecret ($ClientSecret | ConvertTo-SecureString -AsPlainText -Force) `
    -AzureCloudInstance 1
 
#Connect to Graph using access token
Connect-Graph -AccessToken $MsalToken.AccessToken

The error should be gone, then you can connect to Microsoft Graph PowerShell API.

PS C:\> Import-Module MSAL.PS -Force
PS C:\> $MsalToken = Get-MsalToken `
>>     -TenantId $TenantId `
>>     -ClientId $ClientId `
>>     -ClientSecret ($ClientSecret | ConvertTo-SecureString -AsPlainText -Force) `
>>     -AzureCloudInstance 1

PS C:\> Get-MgContext

ClientId              : 87c980ca-a1dd-4748-98db-8007af2bdc70
TenantId              : c032627b-6715-4e39-9990-bcf48ee5e0c5
CertificateThumbprint :
Scopes                : {User.ReadWrite.All}
AuthType              : UserProvidedAccessToken
AuthProviderType      : UserProvidedToken
CertificateName       :
Account               :
AppName               : MrGraph
ContextScope          : Process
Certificate           :
PSHostVersion         : 5.1.22621.1778

Read more: AzureCloudInstance Enum

Not a reader? Watch this related video tutorial:

5/5 - (1 vote)
Previous Post

How to Shrink the Virtual Disk of a Linux Distro in WSL

Next Post

How to SSH Access to a WSL Distro from a Remote Computer

Related Posts

Running Hyper-V and VMware Workstation on The Same Machine

August 15, 2024

How to Uninstall All Autodesk Products At Once Silently

July 29, 2024
Ftr5

How to Uninstall the Autodesk Genuine Service on Windows

July 29, 2024
Ftr19

How to Fix Windows Cannot Read the ProductKey From the Unattend Answer File in VirtualBox

July 26, 2024
Ftr25

How to Update Windows Terminal in Windows 10/11

July 26, 2024

How to Disable The Beep Sound in WSL Terminal on Windows

July 26, 2024

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • How To Turn On uBlock Origin Extension in Chrome (2025)
  • Images Hidden Due To Mature Content Settings In CivitAI
  • Azure OpenAI vs Azure AI Hub, How to Choose the Right One for Your Needs

Categories

Stay in Touch

Discord Server

Join the Discord server with the site members for all questions and discussions.

Telegram Community

Jump in Telegram server. Ask questions and discuss everything with the site members.

Youtube Channel

Watch more videos, learning and sharing with Leo ❤❤❤. Sharing to be better.

Newsletter

Join the movement and receive our weekly Tech related newsletter. It’s Free.

General

Microsoft Windows

Microsoft Office

VMware

VirtualBox

Technology

PowerShell

Microsoft 365

Microsoft Teams

Email Servers

Copyright 2025 © All rights Reserved. Design by Leo with ❤

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory