Run non-powershell command on remote computer.

Welcome Forums General PowerShell Q&A Run non-powershell command on remote computer.

This topic contains 2 replies, has 3 voices, and was last updated by

3 years ago.

  • Author
  • #38586

    Topics: 1
    Replies: 0
    Points: 0
    Rank: Member

    I'm attempting to automate some Treesize reports using powershell. I can run the report fine from the server, but if I try to do this remotely in a scriptblock it doesn't run and I feel like I must be missing something small and silly.

    Here is what I'm doing which seems to give me the correct syntax, but doesn't do anything.
    $target = computer2
    $executable = "c:\program files (x86)\JAM Software\TreeSize Professional\treesize.exe"
    $command = "$executable /Date /HTML `"\\$target\c$\disk.html`" `"\\$target\c$`""
    invoke-command -computername computer2 -scriptblock {$executable}

    Any tips on how to get this working?

  • #38589

    Topics: 1
    Replies: 7
    Points: 0
    Rank: Member

    You are trying to execute $executable in your invoke-command statement, but I think you mean to execute $command.

  • #38638

    Topics: 13
    Replies: 4872
    Points: 1,811
    Helping HandTeam Member
    Rank: Community Hero

    You're likely to run into a problem asking a remote session to access a UNC – this is the double hop problem, and it's explained in "Secrets of PowerShell Remoting."

The topic ‘Run non-powershell command on remote computer.’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort