rights denied with invoke command

This topic contains 3 replies, has 2 voices, and was last updated by  Sam Boutros 11 months, 2 weeks ago.

  • Author
    Posts
  • #55249

    Thomas Delepaut
    Participant

    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
    Participant

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

    Thomas Delepaut
    Participant

    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.
    Thks

    • #55273

      Sam Boutros
      Participant
      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.