Closed
Description
Prerequisites
- I have written a descriptive issue title.
- I have searched all open and closed 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
if i paste my input into my script, it shows error.
however, if i type them line by line, there wont be any error and runs smoothly.
this only happens in debugging(set breakpoints).
PowerShell Version
Name Value
---- -----
PSVersion 7.5.0
PSEdition Core
GitCommitId 7.5.0
OS Microsoft Windows 10.0.26120
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Name : ConsoleHost
Version : 7.5.0
InstanceId : f39c9f54-ffe9-4734-9ad8-35fbc958b513
UI : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture : zh-CN
CurrentUICulture : zh-CN
PrivateData : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled : True
IsRunspacePushed : False
Runspace : System.Management.Automation.Runspaces.LocalRunspace
Visual Studio Code Version
PS C:\Users\Victor\Other\Apps> code --version
1.97.2
e54c774e0add60467559eb0d1e229c6452cf8447
x64
Extension Version
PS C:\Users\Victor\Other\Apps> code --list-extensions --show-versions | Select-String powershell
ms-vscode.powershell@2025.0.0
Steps to Reproduce
[string[]]$domains = $null
while ($true) {
$inp = Read-Host
if ([string]::IsNullOrEmpty($inp)) {
break
}
$domains += $inp
}
[string]$rules = "--host-rules="""
[string]$resolver = "--host-resolver-rules="""
for ($i = 0; $i -lt $domains.Count; $i++) {
[string]$check = q.exe $domains[$i] A `@https://dns.quad9.net
[string]$ip = ($check.Split() | Select-String -Pattern "\d{1,}\.\d{1,}\.\d{1,}\.\d{1,}")[0]
if (-not $i -eq 0) {
$rules += ","
$resolver += ","
}
$rules += "MAP *$($domains[$i]) url$i"
$resolver += "MAP url$i $ip"
}
$rules += """"
$resolver += """"
start-process "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" -ArgumentList "$rules $resolver --test-type --ignore-certificate-errors"
input: (pasting)
github.com
pixiv.net
exhentai.org
error:
InvalidOperation: C:\Users\Victor\Other\Programs\Scripts\sni.ps1:13:5
Line |
13 | [string]$ip = ($check.Split() | Select-String -Pattern "\d{1,}\.\ …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Cannot index into a null array.
InvalidOperation: C:\Users\Victor\Other\Programs\Scripts\sni.ps1:13:5
Line |
13 | [string]$ip = ($check.Split() | Select-String -Pattern "\d{1,}\.\ …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Cannot index into a null array.
P.S. q.exe is [https://github.com/natesales/q]
Visuals
[https://1drv.ms/v/c/77c324b406508168/EZgTrStUAfpGuZO3bA6n7hEBSzeS999JyAEuSPnbfG05gg]
Logs
No response