Out-File within Script Block Access Denied?

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.




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.

Might be this:


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

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

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.