You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
VSCode Version: 1.17.0
OS Edition: Windows 10 Pro
OS Version: 1703
OS Build: 15063.674
Ext Version: 1.4.3
1.17.2
b813d12980308015bcd2b3a2f6efa5c810c33ba5
Major Minor Build Revision
----- ----- ----- --------
1 4 1 0
ms-vscode.PowerShell@1.4.3
robertohuertasm.vscode-icons@7.15.0
Key : PSVersion
Value : 5.1.15063.674
Name : PSVersion
Key : PSEdition
Value : Desktop
Name : PSEdition
Key : PSCompatibleVersions
Value : {1.0, 2.0, 3.0, 4.0...}
Name : PSCompatibleVersions
Key : BuildVersion
Value : 10.0.15063.674
Name : BuildVersion
Key : CLRVersion
Value : 4.0.30319.42000
Name : CLRVersion
Key : WSManStackVersion
Value : 3.0
Name : WSManStackVersion
Key : PSRemotingProtocolVersion
Value : 2.3
Name : PSRemotingProtocolVersion
Key : SerializationVersion
Value : 1.1.0.1
Name : SerializationVersion
Issue Description
PsScriptAnalyzer Falsely Recognizes Global Variable As Assigned But Not Used
Obviously not a critical issue but it is kind of annoying having that green squiggly line under a variable that WILL be used.
Repro Steps
Open VS Code and create a PowerShell file (PowerShell extension installed obviously).
Paste the below example code.
Note that $global:eventType is underlined as a 'PSUseDeclaredVarsMoreThanAssignments' error.
functionWrite-ErrorDetails {
$global:eventType='Error'Write-Error-Message 'An error happened.'-ErrorId $statusCode
}
try {
Write-Output'hello world'$statusCode=0throw'eventType variable is totally going to get used now!'
}
catch {
$statusCode=1Write-ErrorDetails
}
finally {
Write-EventLog-LogName 'Applicatoin'-Source 'MyScript'-EntryType $global:eventType
}
The text was updated successfully, but these errors were encountered:
VSCode Version: 1.17.0
OS Edition: Windows 10 Pro
OS Version: 1703
OS Build: 15063.674
Ext Version: 1.4.3
Issue Description
PsScriptAnalyzer Falsely Recognizes Global Variable As Assigned But Not Used
Obviously not a critical issue but it is kind of annoying having that green squiggly line under a variable that WILL be used.
Repro Steps
$global:eventType
is underlined as a 'PSUseDeclaredVarsMoreThanAssignments' error.The text was updated successfully, but these errors were encountered: