rights denied with invoke command

This topic contains 3 replies, has 2 voices, and was last updated by  Sam Boutros 1 year, 8 months ago.

  • Author
  • #55249

    Thomas Delepaut

    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 😉

  • #55253

    Sam Boutros

    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, 8 months ago by  Sam Boutros.
  • #55268

    Thomas Delepaut

    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 $_.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.

    • #55273

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

      Is this some homework for a PS course!? 🙂

You must be logged in to reply to this topic.