Author Posts

May 4, 2016 at 9:54 am

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?

May 4, 2016 at 10:57 am

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

May 5, 2016 at 7:10 am

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