PSMSALNet 0.1.0 has been released

PSMSALNet 0.1.0 has been released

Hi All,

Just a few Hours ago, i have seen that a new PSMSALNet PowerShell Module has been released. It is used to get EntraID Tokens and is basically a wrapper for MSAL and the Microsoft.Identity.Client.dll.

[0.1.0] - 2024-05-15

Added

  • Added ConvertFrom-Jwt function
  • Added ConvertFrom-Jwt tests

[0.0.9] - 2024-05-10

Added

  • Bump in MSAL version (4.60.3) + all external dependencies
  • Add Get-EntraToken more managed identity exemples into the functions
  • Bump to net8.0 (Powershell 7.4)

Fixed

  • Add FR language support in ConvertTo-X509Certificate2.Tests.ps1 to validate error message.

I am using the new PSResourceGet here instead of the PowerShellGet commands.

Check what is installed and what is available from the PowerShell Gallery

Get-InstalledPSResource PSMSALNet -Scope CurrentUser
Find-PSResource PSMSALNet

Uninstall the old module and install the new Module

Uninstall-PSResource PSMSALNet -Scope CurrentUser
Install-PSResource PSMSALNet -Scope CurrentUser
Get-InstalledPSResource PSMSALNet -Scope CurrentUser

List the Commands of the Module

Get-Command -Module PSMSALNet

Setting up Variables

###############################################################################
# Setting up Variables
###############################################################################
Import-Module PSMSALNet
$TenantId = "46bbad84-29f0-4e03-8d34-f6841a5071ad"
$AppID = "c1a5903b-cd73-48fe-ac1f-e71bde968412"
$RedirectUri = "https://login.microsoftonline.com/common/oauth2/nativeclient"

Authenticate with ClientSecret

###############################################################################
# Authenticate with ClientSecret
###############################################################################
$ClientSecret = "PaZ8Q~-TE92.52FpvTUSXjfUgWUBEOGpud14kbuK"
$HashArguments = @{
  ClientId = $AppID
  ClientSecret = $ClientSecret
  TenantId = $TenantId
  Resource = "GraphAPI"
}
$Token = Get-EntraToken -ClientCredentialFlowWithSecret @HashArguments
$AccessToken = $Token.AccessToken
#$AccessToken
Get-JWTDetails -token $AccessToken

Authenticate with Certificate

###############################################################################
# Authenticate with Certificate
###############################################################################
$CertificateThumbprint = "07EFF3918F47995EB53B91848F69B5C0E78622FD" #O365Powershell3.cer
$Certificate = Get-ChildItem -Path cert:\CurrentUser\my\$CertificateThumbprint

$HashArguments = @{
  ClientId = $AppID
  ClientCertificate = $Certificate
  TenantId = $TenantId
  Resource = "GraphAPI"
}
$Token = Get-EntraToken -ClientCredentialFlowWithCertificate @HashArguments
$AccessToken = $Token.AccessToken
#$AccessToken
Get-JWTDetails -token $AccessToken

Authorization code with PKCE

###############################################################################
# Authorization code with PKCE
###############################################################################
$RedirectUri = "http://localhost"
$HashArguments = @{
  ClientId = $AppID
  TenantId = $TenantId
  RedirectUri = $RedirectUri
  Resource = 'GraphAPI'
  Permissions =  @("Mail.ReadWrite", "Mail.Send", "Calendars.ReadWrite", "Contacts.ReadWrite", "Tasks.ReadWrite")
  verbose = $false
}
$Token = Get-EntraToken -PublicAuthorizationCodeFlow @HashArguments
$AccessToken = $Token.AccessToken
#$AccessToken
Get-JWTDetails -token $AccessToken

Regards
Andres Bohren

M365 Logo

PowerShell Logo