I am working on a PowerShell script that remotely gets veeam Backup reporting data from a backup server. I know we can pass variables usually with $Using:
$object = Invoke-command -ComputerName serverName -ScriptBlock { Get-VBRBackup | Where-Object { $_.JobName -eq $Using:jobName }}
but how can I call method of the object, I tried as below and doesn't work.
$data=Invoke-command -ComputerName serverName -ScriptBlock { $($using:object).GetLocalStorages()}
but if I do :
$data=Invoke-command -ComputerName serverName -ScriptBlock { $(Get-VBRBackup | Where-Object { $_.JobName -eq $Using:jobName }}).GetLocalStorages()}
it works:
I am quite new to PowerShell and don't know much. How to encapsulate alocal objects in invoke-command and call its method?