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

WDAC blocking PSResourceGet because of Dot sourcing in Find-PSResource #1676

Open
3 tasks done
ntatschner opened this issue Jul 19, 2024 · 1 comment
Open
3 tasks done
Labels

Comments

@ntatschner
Copy link

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest released version
  • Search the existing issues.

Steps to reproduce

PowerShell 7.3.4 and 5.1
PSResourceGet
Setup PSResourceRepository
Use Find-PSResource command

Expected behavior

Finds resource

Actual behavior

Throws error

Error details

Find-PSResource: The type initializer for 'Microsoft.PowerShell.PSResourceGet.Cmdlets.UserAgentInfo' threw an exception.

ErrorRecord                 : Cannot dot-source this command because it was defined in a different language mode. To invoke this command without importing its contents, omit the '.' operator.
WasThrownFromThrowStatement : False
TargetSite                  : System.Collections.ObjectModel.Collection`1[System.Management.Automation.PSObject] Invoke(System.Collections.IEnumerable)
Message                     : Cannot dot-source this command because it was defined in a different language mode. To invoke this command without importing its contents, omit the '.' operator.
Data                        : {}
InnerException              : System.NotSupportedException: Cannot dot-source this command because it was defined in a different language mode. To invoke this command without importing its contents, omit the '.' operator.
HelpLink                    : 
Source                      : System.Management.Automation
HResult                     : -2146233087
StackTrace                  :    at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
                                 at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)
                                 at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
                                 at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
                                 at System.Management.Automation.PowerShell.Invoke[T]()
                                 at Microsoft.PowerShell.PSResourceGet.Cmdlets.UserAgentInfo..cctor()

Get-Variable: Cannot find a variable with the name 'PackageManagementProvider'.

Get-Variable: Cannot find a variable with the name 'SourceLocation'.

Get-Variable: Cannot find a variable with the name 'PackageManagementProvider'.

Get-Variable: Cannot find a variable with the name 'SourceLocation'.

Environment data

Directory: C:\program files\powershell\7\Modules
 
ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Binary     1.0.4.1               Microsoft.PowerShell.PSResourceGet  Core,Desk {Find-PSResource, Get-InstalledPSResourc…
 
 
Name                           Value
----                           -----
PSVersion                      7.4.3
PSEdition                      Core
GitCommitId                    7.4.3
OS                             Microsoft Windows 10.0.22631
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

n/A

@SydneyhSmith
Copy link
Collaborator

Thanks @ntatschner it looks like this made it into the preview but not the back port

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

No branches or pull requests

2 participants