Add headless macOS CLI workflow
This commit is contained in:
@@ -138,8 +138,8 @@ function Invoke-InitializeModule
|
||||
}) "MSAL"
|
||||
|
||||
$script:MSALUseWAM = Get-SettingValue "UseWAM"
|
||||
if($script:MSALUseWAM -and $PSVersionTable.PSVersion.Major -lt 7) {
|
||||
Write-Log "WAM is only supported in PowerShell 7 and later. Disabling WAM" 2
|
||||
if($script:MSALUseWAM -and ($PSVersionTable.PSVersion.Major -lt 7 -or -not (Test-IsWindowsPlatform))) {
|
||||
Write-Log "WAM is only supported on Windows with PowerShell 7 and later. Disabling WAM" 2
|
||||
$script:MSALUseWAM = $false
|
||||
}
|
||||
|
||||
@@ -268,7 +268,7 @@ function Get-MSALUserInfo
|
||||
### Only get user info from home tenant
|
||||
$global:Me = $tmpMe
|
||||
Write-Log "Get profile picture"
|
||||
$global:profilePhoto = "$($env:LOCALAPPDATA)\CloudAPIPowerShellManagement\$($global:Me.Id).jpeg"
|
||||
$global:profilePhoto = Join-Path (Get-CloudApiDataFolder) "$($global:Me.Id).jpeg"
|
||||
MSGraph\Invoke-GraphRequest "me/photos/48x48/`$value" -OutFile $global:profilePhoto -SkipAuthentication -NoError | Out-Null
|
||||
}
|
||||
}
|
||||
@@ -517,17 +517,17 @@ function Add-MSALPrereq
|
||||
|
||||
$DLLFiles = @()
|
||||
if($PSVersionTable.PSVersion.Major -ge 7) {
|
||||
$DLLFiles += [IO.FileInfo]($ScriptRoot + "\Bin\Microsoft.IdentityModel.Abstractions.dll")
|
||||
$DLLFiles += [IO.FileInfo](Join-Path $ScriptRoot "Bin/Microsoft.IdentityModel.Abstractions.dll")
|
||||
}
|
||||
else {
|
||||
$DLLFiles += [IO.FileInfo]($ScriptRoot + "\Bin\6.35.0\Microsoft.IdentityModel.Abstractions.dll")
|
||||
$DLLFiles += [IO.FileInfo](Join-Path $ScriptRoot "Bin/6.35.0/Microsoft.IdentityModel.Abstractions.dll")
|
||||
}
|
||||
$DLLFiles += [IO.FileInfo]($ScriptRoot + "\Bin\Microsoft.Identity.Client.dll")
|
||||
$DLLFiles += [IO.FileInfo](Join-Path $ScriptRoot "Bin/Microsoft.Identity.Client.dll")
|
||||
if($script:MSALUseWAM) {
|
||||
$DLLFiles += [IO.FileInfo]($ScriptRoot + "\BIN\$MSALDLLPath\Microsoft.Identity.Client.Extensions.Msal.dll")
|
||||
$DLLFiles += [IO.FileInfo]($ScriptRoot + "\BIN\$MSALDLLPath\Microsoft.Identity.Client.Broker.dll")
|
||||
$DLLFiles += [IO.FileInfo]($ScriptRoot + "\BIN\$MSALDLLPath\Microsoft.Identity.Client.Desktop.dll")
|
||||
$DLLFiles += [IO.FileInfo]($ScriptRoot + "\BIN\$MSALDLLPath\Microsoft.Identity.Client.NativeInterop.dll")
|
||||
$DLLFiles += [IO.FileInfo](Join-Path $ScriptRoot "Bin/$MSALDLLPath/Microsoft.Identity.Client.Extensions.Msal.dll")
|
||||
$DLLFiles += [IO.FileInfo](Join-Path $ScriptRoot "Bin/$MSALDLLPath/Microsoft.Identity.Client.Broker.dll")
|
||||
$DLLFiles += [IO.FileInfo](Join-Path $ScriptRoot "Bin/$MSALDLLPath/Microsoft.Identity.Client.Desktop.dll")
|
||||
$DLLFiles += [IO.FileInfo](Join-Path $ScriptRoot "Bin/$MSALDLLPath/Microsoft.Identity.Client.NativeInterop.dll")
|
||||
}
|
||||
|
||||
$DLLFiles | ForEach-Object {
|
||||
@@ -570,7 +570,7 @@ function Add-MSALPrereq
|
||||
|
||||
try
|
||||
{
|
||||
Add-Type -Path ($ScriptRoot + "\CS\TokenCacheHelperEx.cs") -ReferencedAssemblies $RequiredAssemblies -IgnoreWarnings
|
||||
Add-Type -Path (Join-Path $ScriptRoot "CS/TokenCacheHelperEx.cs") -ReferencedAssemblies $RequiredAssemblies -IgnoreWarnings
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -809,7 +809,7 @@ function Get-MsalAuthenticationToken
|
||||
{
|
||||
# Login hung on rare occations
|
||||
# Workaround: Added DoEvents
|
||||
[System.Windows.Forms.Application]::DoEvents()
|
||||
Invoke-AppDoEvents
|
||||
Start-Sleep -Seconds 1
|
||||
}
|
||||
}
|
||||
@@ -954,7 +954,7 @@ function Get-MSALApp
|
||||
|
||||
if($global:SkipTokenCacheHelperEx -ne $true -and (Get-SettingValue "CacheMSALToken"))
|
||||
{
|
||||
[TokenCacheHelperEx]::EnableSerialization($msalApp.UserTokenCache, "%LOCALAPPDATA%\CloudAPIPowerShellManagement\msalcahce.bin3")
|
||||
[TokenCacheHelperEx]::EnableSerialization($msalApp.UserTokenCache, (Join-Path (Get-CloudApiDataFolder) "msalcahce.bin3"))
|
||||
}
|
||||
$script:MSALAllApps += $msalApp
|
||||
}
|
||||
@@ -1350,7 +1350,7 @@ function Connect-MSALUser
|
||||
|
||||
if((Get-SettingValue "CacheMSALToken"))
|
||||
{
|
||||
[TokenCacheHelperEx]::EnableSerialization($app.UserTokenCache, "%LOCALAPPDATA%\CloudAPIPowerShellManagement\msalcahce.bin3")
|
||||
[TokenCacheHelperEx]::EnableSerialization($app.UserTokenCache, (Join-Path (Get-CloudApiDataFolder) "msalcahce.bin3"))
|
||||
}
|
||||
|
||||
### Silent login
|
||||
@@ -2377,4 +2377,4 @@ function Show-MSALDecodedToken {
|
||||
Show-ModalForm $title $dg
|
||||
}
|
||||
|
||||
Export-ModuleMember -alias * -function *
|
||||
Export-ModuleMember -alias * -function *
|
||||
|
||||
Reference in New Issue
Block a user