Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graph-MgConnect error: Entry point was not found. Powershell 7.5.0 #3133

Open
alessandroere opened this issue Feb 14, 2025 · 4 comments
Open
Labels
feedback no-recent-activity status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close type:bug A broken experience

Comments

@alessandroere
Copy link

alessandroere commented Feb 14, 2025

Describe the bug

I have a strange behavior using graph api. If i run a script through Visual Studio Code and Powershell extantion all works well but if i schedule the same script with task scheduler i get the entry point not found error.
I'm using powershell 7.5.0 for both Visual Studio Code and task scheduler execution. I have a lot of script run with task scheduler and all have the same issue.
As installed module i have only Graph module, MSAL.PS and SimplySql

This is the action configured on task scheduler:
Program/script: "C:\Program Files\PowerShell\7\pwsh.exe"
Add Arguments: -ExecutionPolicy Bypass -File "C:\script\test.ps1"

The execution policy is set to RemoteSign for both LocalMachine and CurrentUser

Expected behavior

If script execution works in visual studio code than it should also work with task scheduler

How to reproduce

schedule script with task scheduler

SDK Version

2.25.0

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output

Click to expand log ```

PowerShell transcript start
Start time: 20250214192336
Username: CORPABSTR....
RunAs User: CORPABSTR....
Configuration Name:
Machine: ABS-DC2 (Microsoft Windows NT 10.0.14393.0)
Host Application: C:\Program Files\PowerShell\7\pwsh.dll -ExecutionPolicy Bypass -File C:\script\RenewConsultants\RenewConsultants.ps1
Process ID: 7048
PSVersion: 7.5.0
PSEdition: Core
GitCommitId: 7.5.0
OS: Microsoft Windows 10.0.14393
Platform: Win32NT
PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1, 6.0, 7.0
PSRemotingProtocolVersion: 2.3
SerializationVersion: 1.1.0.1
WSManStackVersion: 3.0


Transcript started, output file is C:\script\RenewConsultants\logs\transcript.txt
DEBUG: ClientCertificateCredential.GetToken invoked. Scopes: [ https://graph.microsoft.com/.default ] ParentRequestId:
DEBUG: False MSAL 4.66.1.0 MSAL.NetCore .NET 9.0.1 Microsoft Windows 10.0.14393 [2025-02-14 18:23:36Z - 922e791c-3626-46c6-ae91-aaadc725a01d] MSAL MSAL.NetCore with assembly version '4.66.1.0'. CorrelationId(922e791c-3626-46c6-ae91-aaadc725a01d)
DEBUG: False MSAL 4.66.1.0 MSAL.NetCore .NET 9.0.1 Microsoft Windows 10.0.14393 [2025-02-14 18:23:36Z - 922e791c-3626-46c6-ae91-aaadc725a01d] === AcquireTokenForClientParameters ===
SendX5C: False
ForceRefresh: False
DEBUG: False MSAL 4.66.1.0 MSAL.NetCore .NET 9.0.1 Microsoft Windows 10.0.14393 [2025-02-14 18:23:36Z - 922e791c-3626-46c6-ae91-aaadc725a01d]
=== Request Data ===
Authority Provided? - True
Scopes - https://graph.microsoft.com/.default
Extra Query Params Keys (space separated) -
ApiId - AcquireTokenForClient
IsConfidentialClient - True
SendX5C - False
LoginHint ? False
IsBrokerConfigured - False
HomeAccountId - False
CorrelationId - 922e791c-3626-46c6-ae91-aaadc725a01d
UserAssertion set: False
LongRunningOboCacheKey set: False
Region configured:
DEBUG: False MSAL 4.66.1.0 MSAL.NetCore .NET 9.0.1 Microsoft Windows 10.0.14393 [2025-02-14 18:23:36Z - 922e791c-3626-46c6-ae91-aaadc725a01d] === Token Acquisition (ClientCredentialRequest) started:
Scopes: https://graph.microsoft.com/.default
Authority Host: login.microsoftonline.com
DEBUG: False MSAL 4.66.1.0 MSAL.NetCore .NET 9.0.1 Microsoft Windows 10.0.14393 [2025-02-14 18:23:36Z] [Internal cache] Clearing app token cache accessor.
DEBUG: False MSAL 4.66.1.0 MSAL.NetCore .NET 9.0.1 Microsoft Windows 10.0.14393 [2025-02-14 18:23:36Z - 922e791c-3626-46c6-ae91-aaadc725a01d] [Internal cache] Total number of cache partitions found while getting access tokens: 0
DEBUG: False MSAL 4.66.1.0 MSAL.NetCore .NET 9.0.1 Microsoft Windows 10.0.14393 [2025-02-14 18:23:36Z - 922e791c-3626-46c6-ae91-aaadc725a01d] [FindAccessTokenAsync] Discovered 0 access tokens in cache using partition key: d18e5660-6c3a-4084-8952-8ecc666c5592_5f4c80c0-58ee-4e80-8990-b80e85ad9e5b_AppTokenCache
DEBUG: False MSAL 4.66.1.0 MSAL.NetCore .NET 9.0.1 Microsoft Windows 10.0.14393 [2025-02-14 18:23:36Z - 922e791c-3626-46c6-ae91-aaadc725a01d] [Instance Discovery] Instance discovery is enabled and will be performed
DEBUG: False MSAL 4.66.1.0 MSAL.NetCore .NET 9.0.1 Microsoft Windows 10.0.14393 [2025-02-14 18:23:36Z - 922e791c-3626-46c6-ae91-aaadc725a01d] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.66.1.0 MSAL.NetCore .NET 9.0.1 Microsoft Windows 10.0.14393 [2025-02-14 18:23:36Z - 922e791c-3626-46c6-ae91-aaadc725a01d] Fetching instance discovery from the network from host login.microsoftonline.com.
DEBUG: Request [2a3c206e-8648-4401-815c-61718aa5c0f1] GET https://login.microsoftonline.com/common/discovery/instance?api-version=1.1&authorization_endpoint=REDACTED
x-client-SKU:REDACTED
x-client-Ver:REDACTED
x-client-OS:REDACTED
client-request-id:REDACTED
return-client-request-id:REDACTED
x-ms-client-request-id:2a3c206e-8648-4401-815c-61718aa5c0f1
x-ms-return-client-request-id:true
User-Agent:azsdk-net-Identity/1.13.1 (.NET 9.0.1; Microsoft Windows 10.0.14393)
client assembly: Azure.Identity
Connect-MgGraph: C:\script\RenewConsultants\RenewConsultants.ps1:731
Line |
731 | Connect-MgGraph -ClientID $microsoftGraph.appID -TenantId $micros …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Entry point was not found.
Connect-MgGraph: C:\script\RenewConsultants\RenewConsultants.ps1:731
Line |
731 | Connect-MgGraph -ClientID $microsoftGraph.appID -TenantId $micros …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Entry point was not found.


PowerShell transcript end
End time: 20250214192337


</details>


### Configuration

$PSVersionTable output:
Name                           Value
----                           -----
PSVersion                      7.5.0
PSEdition                      Core
GitCommitId                    7.5.0
OS                             Microsoft Windows 10.0.14393
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

OS Version:
Edition: Windows Server 2016
Version: 1607
OS Build: 14393.7785

Architecture:
x64

### Other information

_No response_
@alessandroere alessandroere added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Feb 14, 2025
@timayabi2020
Copy link
Contributor

Hi @alessandroere maybe you could be having library conflicts between MSAL and graph PowerShell. Please share the output of this command. [system.AppDomain]::CurrentDomain.GetAssemblies() | Where-Object Location | Sort-Object -Property FullName | Select-Object -Property FullName, Location | Out-GridView

@timayabi2020 timayabi2020 added feedback status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close and removed status:waiting-for-triage An issue that is yet to be reviewed or assigned labels Feb 14, 2025
@alessandroere
Copy link
Author

alessandroere commented Feb 15, 2025

Hi @timayabi2020

This output is direct from Powershell via Visual Studio Code
outFileFromPowershellCli.txt

This output is direct from task scheduler execution

outFileFromPowershellFromTaskScheduler.txt

Thank you

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Attention 👋 and removed status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close labels Feb 15, 2025
@timayabi2020
Copy link
Contributor

@alessandroere if you compare the two files, the output from the task scheduler is missing the Azure.Identity assembly hence the error.

Maybe you can try reinstalling the SDK with these parameters at the end -AllowClobber -Force or you can manually add the assembly in the script referenced by the task scheduler. i.e.

$IdentityLibPath = "C:\Program Files\PowerShell\Modules\Microsoft.Graph.Authentication\2.25.0\Dependencies"
Add-Type -AssemblyName (Join-Path $IdentityLibPath "Azure.Identity.dll")

@timayabi2020 timayabi2020 added status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close and removed Needs: Attention 👋 labels Feb 19, 2025
Copy link
Contributor

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feedback no-recent-activity status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close type:bug A broken experience
Projects
None yet
Development

No branches or pull requests

2 participants