PowerShell / PowerShell/vscode-powershell

Cannot get path of running script in $MyInvocation.InvocationName

Offen
#3,959 19 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Area-Debugging Bug: PowerShell 5.1 Bug: PowerShell Core Issue-Bug
Vorherrschende Sprache
TypeScript
Sterne
1.9k
Forks
548
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

Prerequisites
  • I have written a descriptive issue title.
  • I have searched all issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
  • If this is a security issue, I have read the security issue reporting guidance.
Summary

In versions 2022.5.0 and 2022.5.1
To get the path of a running script.
i tried
$MyInvocation.InvocationName
but I could not get the path by this command.

Similarly, to retrieve the path of a script running on
$PSScriptRoot
This also did not retrieve the path.

I downgraded the version to 2021.12.0 and got the path correctly

Thank you

Translated with www.DeepL.com/Translator

PowerShell Version
Name                           Value
----                           -----
PSVersion                      7.2.3
PSEdition                      Core
GitCommitId                    7.2.3
OS                             Microsoft Windows 10.0.19044
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Visual Studio Code Version
1.67.0
57fd6d0195bb9b9d1b49f6da5db789060795de47
x64
Extension Version
don't work
2022.5.0 and 2022.5.1

work
ms-vscode.powershell@2021.12.0
Steps to Reproduce

$MyInvocation.InvocationName

Visuals

No response

Logs

No response

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Reproduziere das Problem in der PowerShell-Erweiterung mit PowerShell 7.2.3 und VS Code 1.67.0, indem du $MyInvocation.InvocationName ausführst und $PSScriptRoot überprüfst. Vergleiche das Verhalten mit der Erweiterungsversion 2021.12.0 und den Versionen 2022.5.0/2022.5.1; abgeschlossen ist die Aufgabe, wenn der Skriptpfad wiederhergestellt wurde, ohne die funktionierende Version zu beeinträchtigen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
powershell, typescript, vscode
Bereich
devtools
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
38/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.