Invoke-Command
returns the output, not the objects created. If you want to remotely operate COM objects via Invoke-Command
you have to include the code in the script block:
$foldername = "C:\test"
$computername ="remotecomputer"
Invoke-Command -ComputerName $computername -ScriptBlock {
$newquotaobj = New-Object -ComObject Fsrm.FsrmQuotaManager
$newquotasrc = $newquotaobj.GetQuota($args[0])
$newquotasrc # <-- this will be returned to the local host
} -ArgumentList $foldername