Hello!
I have a script that used Start-Job to start Get-ChildItem script. For reasons that are too long to get into, I wanted to try this methodology with Invoke-Command instead!
The command looks like this:
$a = Invoke-Command -AsJob -ComputerName $env:computername -ScriptBlock { Get-ChildItem -Path C:\ *.exe } echo $a
However, instead of $a containing the output for the Get-Childitem command ( a list of executables), it instead contains the output for the job!
Id Name PSJobTypeName State HasMoreData Location Command -- ---- ------------- ----- ----------- -------- ------- 15 Job15 RemoteJob Running True WIN-GNNG6UDHR6J ...
What am I doing wrong?
I have attempted to use Receive-Job but have had no success yet. This is the error I get when I try to receive-job
Connecting to remote server WIN-GNNG6UDHR6J failed with the following error message : Access is denied. For more information, see the about_Remote_Troubleshooting Help topic. + CategoryInfo : OpenError: (WIN-GNNG6UDHR6J:String) [], PSRemotingTransportException + FullyQualifiedErrorId : AccessDenied,PSSessionStateBroken
Thanks ahead of time!