Quantcast
Channel: Windows PowerShell Forum
Viewing all articles
Browse latest Browse all 2562

Access denied on remote script - Newbie

$
0
0

First off I apologize but I am a complete newbie and powershell.

I have written a PS script that looks through a server's event logs and parses out WARNING/ERRORS and writes them to a text file on my primary domain controller's E:\ drive which I use to collect logs daily for review, the script writes to this location by doing  \\primaryDChostname\E$\filename.txt

The script runs great if its running locally on the machine (any machine) and it'll write the text file to the E: drive on the primary DC no problem.

I decided its not efficient to have the script on every server running as a scheduled task on every server so I wanted to clean it up a bit.

I decided to write another PS script that runs my eventlog script remotely on all the servers that way the script is on 1 machine only and only 1 scheduled task is needed on my server hosting the script.

THE PROBLEM:

Well the 2nd script works only on the backup domain controller, it creates the text files on my primaryDC E:\ drive with no issues, however, when the script hits the member servers it fails with the following:

Access to the path '\\PRIMARYDC\E$\ApplogERRORS.txt' is denied

OpenError:(:)[], UnauthorizedAccessException

FileOpenFailure

Permissions on E: on my primary DC are wide open, EVERYONE full control. If I run my event log script locally on a member server it has no issues writing the text file to the E:\ drive on my Primary DC so I dont understand if its trully file permissions issue.

I'm assuming it works on my backup DC because there is a full trust between it and the primary DC that doesn't exist on the member servers? I'm guessing here...??

Here is the secondary script syntax that kicks off my eventlog script:

invoke-command -computername BACKUPDOMAINCONTROLLER, SERVER1, SERVER2, -filepath 'E:\Filterlogs.ps1's

So it works fine on the backupDC and the files are created on my primaryDC E:\drive but it failson SERVER1, SERVER2 ect...

I have run the following commands (as admin) on all machines:

Set-Executionpolicy unrestricted

Enable-PSRemoting -Force

Thoughts?


Viewing all articles
Browse latest Browse all 2562

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>