PSResourceGet
PSResourceGet copied to clipboard
WDAC blocking PSResourceGet because of Dot sourcing in Find-PSResource
Prerequisites
- [X] Write a descriptive title.
- [X] Make sure you are able to repro it on the latest released version
- [X] 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