Azure / Azure/azure-powershell-common
Import-Module PowerShellGet error: Cannot find a variable with the name 'AmsiContext'
- 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:

Contributor 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