0

I am connecting to a windows device from the host using Open-Device in Powershell. i have to run a command in remote PC and capture the output into a variable to process further, unable to do so. tried redirecting using 'Out-String', 'Tee' Operation, Redirect the out put to a file, extract data from STDOUT etc. nothing seems to be working.

Output is printing onto the STDOUT but could not extract

Code i tried.

Open-Device <Device Serial Number>
cmdd dir
2
  • Have you tried Start-Transcript -Path "logfile.txt" / Stop-Transcript to capture stdout to a file for processing? Commented Apr 4, 2024 at 9:11
  • i tried it. did not help. Commented Apr 4, 2024 at 9:29

1 Answer 1

0
$cmdoutput = cmdd dir

$cmdoutput.Output has the required data for Remote commands. able to process the remote command output with .Output

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.