Author Posts

October 12, 2016 at 4:09 pm

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 😉

October 12, 2016 at 5:53 pm

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
  • This reply was modified 1 year, 11 months ago by  Sam Boutros.

October 13, 2016 at 9:29 am

thk u sam it works 😉
An other issue. i d like list all local drive and next list directory:
i did :
get-psdrive -psprovider filesystem | foreach-objet {ls $ :\}
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.

October 13, 2016 at 12:44 pm

Get-PSDrive -PSProvider FileSystem | 
    ForEach-Object {
        Get-ChildItem -Path "$($\" -Directory

Is this some homework for a PS course!? 🙂