Azure / Azure/CloudShell

PowerShell: "The variable '$elapsed' cannot be retrieved because it has not been set."

Open
#284 0 comments 0 reactions 1 assignee Claimed by @theJasonHelmick View on GitHub
Area-image bug Iteration-Backlog
Dominant language
PowerShell
Stars
273
Forks
117
Avg merge
1h
Merged PRs (30d)
2

Description

When I now log in to Azure Cloud Shell using PowerShell I get this error:

```
InvalidOperation: /opt/microsoft/powershell/7/profile.ps1:268
Line |
268 | if($elapsed -gt '1000')
| ~~~~~~~~
| The variable '$elapsed' cannot be retrieved because it has not been set.
```
here's what is happening:
image

The profile file `/opt/microsoft/powershell/7/profile.ps1` is part of the Azure Cloud Shell.

I have `Set-StrictMode -Version latest` in my PowerShell profile. If I remove this the error goes away.

I think the default for Azure Cloud Shell PowerShell should use strict mode to catch unnecessary issues.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.