Run non-powershell command on remote computer.

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?

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

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.”