How to pull subfolders via remote scripting

2 posts · Closed

Keith Guest
12 Feb 2025

Hello. How do I get this to work in remote scripting? I am trying to pull the subfolder from a folder on remote computers.

Const Quote = """"

Dim cmd
cmd = "powershell.exe " "Get-ChildItem -Path "\\computername\C$\Program Files\SentinelOne -directory ""

'Create process object and execute PowerShell
Set proc = Internal.CreateObject("process")
proc.execute(cmd)

'Check process exit code
If proc.ExitCode = 0 Then

'Traverse output lines
For Each line in proc.output
Output.Write Line
Next
Else
Output.Write "Exit code " & proc.ExitCode
End If
Ann SoftPerfect
12 Feb 2025

It looks like quotation marks were used incorrectly in your script. It is easier to place everything in a single string. Below is a working example. You can replace the path with C:\ for testing.

Dim cmd
cmd = "powershell.exe Get-ChildItem -Path \\computername\C$\Program Files\SentinelOne -directory"

'Create process object and execute PowerShell
Set proc = Internal.CreateObject("process")
proc.execute(cmd)

'Check process exit code
If proc.ExitCode = 0 Then

'Traverse output lines
For Each line in proc.output
Output.Write Line
Next
Else
Output.Write "Exit code " & proc.ExitCode
End If
This topic is closed. It has had no new posts for over a year, so the software versions it talks about may be out of date. Start a new topic in Network Scanner if you have a similar question.