Skip to content
This repository was archived by the owner on Jun 16, 2021. It is now read-only.
This repository was archived by the owner on Jun 16, 2021. It is now read-only.

Error when importing a windows module in $profile using 1.0.0.rc1  #56

@KaylorDave

Description

@KaylorDave

When importing a module inside of the PowerShell profile, the WindowsCompatibility module is throwing an error regarding Set-Location and $PSBoundParameters. The imported module still works correctly, but this slows down profile loading significantly (and adds red to my PowerShell sessions immediately).

pwsh version info-

PS C:\Users\kaylorw> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.1.0
PSEdition                      Core
GitCommitId                    6.1.0
OS                             Microsoft Windows 10.0.17763
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Contents of $profile file-
Import-WinModule -Name microsoft.powershell.management

Error text received-

Set-Location : The variable '$PSBoundParameters' cannot be retrieved because it has not been set.
+ CategoryInfo          : InvalidOperation: (PSBoundParameters:String) [Set-Location], RuntimeException
+ FullyQualifiedErrorId : VariableIsUndefined,Microsoft.PowerShell.Commands.SetLocationCommand

Full error context-

ErrorRecord                 : The variable '$PSBoundParameters' cannot be retrieved because it has not been set.
WasThrownFromThrowStatement : False
Message                     : The variable '$PSBoundParameters' cannot be retrieved because it has not been set.
Data                        : {}
InnerException              : System.Management.Automation.RuntimeException: The variable '$PSBoundParameters' cannot
                              be retrieved because it has not been set.
                                 at
                              System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext
                              funcContext, Exception exception)
                                 at
                              System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame
                              frame)
                                 at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(Interp
                              retedFrame frame)
                                 at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(Interp
                              retedFrame frame)
                                 at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame)
                                 at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0)
                                 at
                              System.Management.Automation.ScriptBlock.InvokeWithPipeImpl(ScriptBlockClauseToInvoke
                              clauseToInvoke, Boolean createLocalScope, Dictionary`2 functionsToDefine, List`1
                              variablesToDefine, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder,
                              Object input, Object scriptThis, Pipe outputPipe, InvocationInfo invocationInfo,
                              Object[] args)
                                 at
                              System.Management.Automation.ScriptBlock.<>c__DisplayClass57_0.<InvokeWithPipe>b__0()
                                 at System.Management.Automation.Runspaces.RunspaceBase.RunActionIfNoRunningPipelinesWi
                              thThreadCheck(Action action)
                                 at System.Management.Automation.ScriptBlock.InvokeWithPipe(Boolean useLocalScope,
                              ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object
                              scriptThis, Pipe outputPipe, InvocationInfo invocationInfo, Boolean
                              propagateAllExceptionsToTop, List`1 variablesToDefine, Dictionary`2 functionsToDefine,
                              Object[] args)
                                 at System.Management.Automation.ScriptBlock.InvokeAsDelegateHelper(Object
                              dollarUnder, Object dollarThis, Object[] args)
                                 at lambda_method(Closure , Object , LocationChangedEventArgs )
                                 at System.Management.Automation.SessionStateInternal.SetLocation(String path,
                              CmdletProviderContext context)
                                 at System.Management.Automation.PathIntrinsics.SetLocation(String path,
                              CmdletProviderContext context)
                                 at Microsoft.PowerShell.Commands.SetLocationCommand.ProcessRecord()
                                 at System.Management.Automation.Cmdlet.DoProcessRecord()
                                 at System.Management.Automation.CommandProcessor.ProcessRecord()
TargetSite                  : System.Collections.ObjectModel.Collection`1[System.Management.Automation.PSObject]
                              Invoke(System.Collections.IEnumerable)
StackTrace                  :    at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
                                 at System.Management.Automation.Runspaces.Pipeline.Invoke()
                                 at Microsoft.PowerShell.Executor.ExecuteCommandHelper(Pipeline tempPipeline,
                              Exception& exceptionThrown, ExecutionOptions options)
HelpLink                    :
Source                      : System.Management.Automation
HResult                     : -2146233087

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions