Azure / Azure/azure-powershell-common

Import-Module PowerShellGet error: Cannot find a variable with the name 'AmsiContext'

Open
#304 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
36
Forks
62
PR merge metrics
No merged PRs in 30d

Description

Can anyone help me with this issue?

When I execute this command:

`Import-Module PowerShellGet`

I got this error:

```
Import-Module : Cannot find a variable with the name 'AmsiContext'.
At line:1 char:1
+ Import-Module PowerShellGet
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (AmsiContext:String) [Import-Module], ItemNotFoundException
+ FullyQualifiedErrorId : VariableNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
```

The second time it goes fine:

![image](https://user-images.githubusercontent.com/28626283/144410480-66e614ef-fd1e-4ef8-acca-c7b94d02df88.png)

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the reported `Import-Module PowerShellGet` command and verify that the first invocation fails for `AmsiContext` while the second succeeds. The issue names no source files or tests, so trace the module-import initialization path before determining how to prevent the first-load error and confirm repeated imports succeed.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.