"Run selection" does nothing
See original GitHub issueIssue Type: Bug
I have an open Workspace in Visual Code and select a specific PowerShell Script. Then I select the function incl. “get-teamviewerdevices” to run the function. Right click and select “Run selection” or hitting F8 to test the function does nothing.
My next step was to close the Workspace and open the same PowerShell Script on the same place with a right click “Open in Code” and try again. Now it works as expected?! Any ideas or suggestions?
[string]$accessToken = "<token>"
[string]$tvApiVersion = '<apiversion>'
[string]$tvApiBaseUrl = '<URL>'
function Get-TeamViewerDevices {
[CmdletBinding(DefaultParameterSetName = "Policy", SupportsShouldProcess = $true)]
param(
[Parameter(ParameterSetName = 'Policy', Mandatory = $false)]
[ValidateSet('None', 'Inherit')]
[string] $Policy = 'Inherit',
[Parameter(ParameterSetName = 'SpecificPolicy', Mandatory = $true)]
[string] $PolicyId
)
function ConvertTo-TeamViewerRestError {
param([parameter(ValueFromPipeline)]$err)
try { return ($err | Out-String | ConvertFrom-Json) }
catch { return $err }
}
function Invoke-TeamViewerRestMethod {
# Using `Invoke-WebRequest` instead of `Invoke-RestMethod`:
# There is a known issue for PUT and DELETE operations to hang on Windows Server 2012.
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls -bor [Net.SecurityProtocolType]::Tls11 -bor [Net.SecurityProtocolType]::Tls12
try { return ((Invoke-WebRequest -UseBasicParsing @args).Content | ConvertFrom-Json) }
catch [System.Net.WebException] {
$stream = $_.Exception.Response.GetResponseStream()
$reader = New-Object System.IO.StreamReader($stream)
$reader.BaseStream.Position = 0
Throw ($reader.ReadToEnd() | ConvertTo-TeamViewerRestError)
}
}
function Get-TeamViewerDevice($accessToken, $groupId) {
if ($groupId) { $body = @{ groupid = $groupId } }
return Invoke-TeamViewerRestMethod -Uri "$tvApiBaseUrl/api/$tvApiVersion/devices" `
-Method Get -Headers @{authorization = "Bearer $accessToken"} -Body $body
}
try {
$script:devices = (Get-TeamViewerDevice -accessToken $accessToken)
$script:currentdevice = $devices.devices -match $env:COMPUTERNAME
} catch {
Write-Host "No connection with >URL< possible!"
}
}
get-teamviewerdevices
#$assignedFalse = $devices.devices | Select-Object -Property Alias, last_seen, assigned_to | where-object {$_.assigned_to -like "*false*"}
#$lastSeen = $devices.devices | Select-Object -Property Alias, last_seen, assigned_to
$online = $devices.devices | Select-Object -Property Alias, groupid, Online_state, assigned_to | Where-Object {$_.online_state -like "*online*" -and $_.assigned_to -like "*false*"}
foreach ($client in $online) {
$GroupID = $client.groupid
if ($env:PROCESSOR_ARCHITECTURE -eq "AMD64") {
if (Test-Path -Path ${env:ProgramFiles(x86)}\TeamViewer\Teamviewer.exe) {
Invoke-Command -ComputerName $client.alias -ScriptBlock {Start-Process -FilePath ${env:ProgramFiles(x86)}\TeamViewer\TeamViewer.exe -ArgumentList "assign --api-token >token< --group-id $GroupID";Write-Host "Der Client"$client.alias"in der Gruppe"$GroupID" wurde neu zugewiesen.[64]"}
}
} else {
if (Test-Path -Path $env:ProgramFiles\Teamviewer\TeamViewer.exe) {
Invoke-Command -ComputerName $client.alias -ScriptBlock {Start-Process -FilePath $env:ProgramFiles\TeamViewer\TeamViewer.exe -ArgumentList "assign --api-token >token< --group-id $GroupID";Write-Host "Der Client"$client.alias"in der Gruppe"$GroupID" wurde neu zugewiesen.[32]"}
}
}
}
Extension version: 2020.6.0 VS Code version: Code 1.51.1 (e5a624b788d92b8d34d1392e4c4d9789406efe8f, 2020-11-10T23:34:32.027Z) OS version: Windows_NT x64 10.0.18363
Issue Analytics
- State:
- Created 3 years ago
- Comments:26 (5 by maintainers)
Top Results From Across the Web
VS code run selection in interactive window doesn't work
In my case, I was able to solve the problem by changing the when condition in the Keyboard Shortcuts and removing the "&&...
Read more >Code Running Assistance | PyCharm Documentation - JetBrains
Modify the code sample so that it can use a command-line argument value instead of "4" in the calculations. · Open the Solver...
Read more >ImageJ Macro Language
Simple macros can be generated using the command recorder (Plugins>Macros>Record). For example, this macro, which measures and labels a selection,. run("Measure ...
Read more >Hotkeys (mouse, joystick and keyboard shortcuts) - AutoHotkey
However, if a hotkey needs to execute only a single line, that line can be ... Limitations: 1) "Up" does not work with...
Read more >Some users unable to run flow (Power Automate), click...
Some users unable to run flow (Power Automate), click on RUN does nothing, click enter shows country selection. Unanswered.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@pilgi3 the preview has a complete rewrite of the core pipelining engine to help make things faster and more stable. The core of it is stable but there may be many new edge cases here and there we are working to smooth over as a result of such a huge change.
Can you provide some more specifics? Run Selection (F8) works just fine for me on selecting a line in a script and having it run in the PSIC at the bottom. (On my computer I have it bound to alt-enter but it’s the same process)
https://user-images.githubusercontent.com/15258962/152807129-9572ebf4-1472-4405-89c9-f9861092c5ae.mp4
Yes the log files are from an affected device. I will do again and provide the payload logs as well!