rights denied with invoke command

Hi everybody,
I have an issue with a command,
I d like execute on my server X juste a basic ls on a drive and report the result in a text file on my computer.
I do the command with admin domain rights but instead it told me access denied on my computer.
invoke-command -computer MYSERVERX -credential mydomain\admin -scriptblock {ls d:\ > \myipadress\c$\result.txt}
The command is ok but when i write this result text file acess denied.
On my server ps remote is ok, when i write the file on the server ok but my pc don’t have enough rights.
I ve readen on internet it s maybe a double hop problem but i can’t resolve it.
If you can help me thks :wink:

Looks like a 2nd hop issue,
I recommend doing the redirection outside the script block like:

invoke-command -computer MYSERVERX -credential mydomain\admin -scriptblock {ls d:\ } | out-file \\myipadress\c$\result.txt

thk u sam it works :wink:
An other issue. i d like list all local drive and next list directory:
i did :
get-psdrive -psprovider filesystem | foreach-objet {ls $_.name :}
but it told me object not found c:\f:string …
Could you tell me for each property name return by psprovider listing each local drive.

Get-PSDrive -PSProvider FileSystem | 
    ForEach-Object {
        Get-ChildItem -Path "$($_.name):\" -Directory

Is this some homework for a PS course!? :slight_smile: