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
SoftPerfect Support Forum
SoftPerfect Network Scanner
PowerShell in remote scripting
Started by Keith
|
Keith
PowerShell in remote scripting 12 February 2025, 10:47 |
Hello. How do I get this to work in remote scripting? I am trying to pull the subfolder from a folder on remote computers.
|
|
Re: PowerShell in remote scripting 12 February 2025, 11:05 |
Admin Registered: 12 years ago Posts: 1 112 |
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