Unable to store PowerShell output into a variable or file.

Anonymous
2024-03-29T10:22:54+00:00

I am trying to run a PowerShell command from a VM which is connected to other VM and command is actually running over second VM, although output is getting printed on the PowerShell but when I am trying to store it into a variable or file it is coming as empty.

I tried converting output into string I got this when I printed the variable: Microsoft.Texus.Shells.CommandResult
Even transcription is skipping the output.

Windows Windows Client for IT Pros High availability

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question. To protect privacy, user profiles for migrated questions are anonymized.

0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Anonymous
    2024-04-03T06:13:22+00:00

    Hi Tanmay Goel,

    How do you run the commands on the remote VM? Can you post your script?

    0 comments No comments
  2. Anonymous
    2024-04-10T10:36:41+00:00

    Open-Device <Device Serial Number> x = cmdd dir

    We tried the above code, open-device to connect to the PC, x to save the output.
    we tried with Tee, Redirection, Transcription etc.
    
    Posted the same in Stackoverflow as well.
    https://stackoverflow.com/questions/78272214/unable-to-capture-the-output-of-a-remote-command-in-powershell
    
    0 comments No comments
  3. Anonymous
    2024-04-12T04:33:51+00:00

    I'm not sure what open-device is. It's not a PowerShell cmdlet that comes with Windows. Is it an executable or a custom PowerShell function?

    0 comments No comments
  4. Anonymous
    2024-05-07T03:54:33+00:00

    It is from a powershell module TShell : Connect using TShell | Microsoft Learn

    0 comments No comments