Out-File within Script Block Access Denied?

Welcome Forums General PowerShell Q&A Out-File within Script Block Access Denied?

Viewing 4 reply threads
  • Author
    Posts
    • #274134
      Participant
      Topics: 3
      Replies: 3
      Points: 29
      Rank: Member

      Not sure what happened.  I just posted this and I don’t see it, so I’m posting again…

      I’m trying to write a script to query a whole bunch of servers to look in a few different directories and find any files that match a pattern.  Then I want that line appended to a file back on the server I am running the script on.  When I run the script, I’m running it from 01 server and the array’s first item is 01… so it works.  But, when it hits 02, it gets an access denied when trying to write back to 01.

      Below are links to see my code and the error.

      https://www.dropbox.com/s/h8ntcmwa2ckj2er/Capture5.PNG?dl=0

      https://www.dropbox.com/s/4rfw2h42585m3iu/Capture3.PNG?dl=0

       

    • #274137
      Participant
      Topics: 3
      Replies: 3
      Points: 29
      Rank: Member

      Ignore the exit-pssession and remove-pssession.  I was trying new-pssession instead of the invoke command earlier and not having any luck either.  forgot to take it out.

    • #274140
      Participant
      Topics: 10
      Replies: 206
      Points: 1,010
      Helping Hand
      Rank: Community Hero

      Might be this:

      https://blog.ipswitch.com/the-infamous-double-hop-problem-in-powershell

      I am unable to see your shots as our company blocks dropbox.

    • #274173
      Participant
      Topics: 9
      Replies: 707
      Points: 2,848
      Helping Hand
      Rank: Community Hero

      You ever heard of the double hop issue? Seems like the problem to me

    • #274176
      Participant
      Topics: 3
      Replies: 3
      Points: 29
      Rank: Member

      I have heard of the double hop.  I was first using the new-pssession and then exiting it.  I was getting the error and that’s when I found the double hop issue.  But, the website I found said to use the invoke-command instead to get around that.

Viewing 4 reply threads
  • You must be logged in to reply to this topic.