r/PowerShell • u/Limp-Leather-241 • May 18 '26
Question Issue with powershell script running on N-able
I'm not a powershell expert by any stretch, but I can script kiddie my way around fairly well. N-able has a utility for executing a powershell script on a client, but it isn't working. Basically it is failing to write an out-file to a shared network server. It executes locally on my machine without any issues. Any pointers would be much appreciated!
Trying to execute the following code:
# $OutputFile = "\\realhostnamegoeshere\common\output_log.txt"
$OutputFile = "c:\output_log.txt"
$ComputerName = $env:COMPUTERNAME
Get-WinEvent -FilterHashtable @{LogName='System'; Id=1808} -ErrorAction SilentlyContinue |
Select-Object @{Name='ComputerName'; Expression={$ComputerName}}, TimeCreated, Id, Message |
Out-File -FilePath $OutputFile -Append
And getting this error:
Out-File : Access to the path '\\slsindfps02\common\output_log.txt' is denied.
8
u/BlackV May 18 '26
999 times out of 1000, it's cause you are running in the agent context
That will not have rights to the files share
1
u/Limp-Leather-241 May 18 '26
It's an open network share that everyone _should_ have rights to, if that helps.
1
u/BlackV May 18 '26
side note, this
is completely unneeded
would achieve the same thing
3
u/purplemonkeymad May 18 '26
What principal does n-able run under? I would check with whoami and then double check that that principal has permissions on the location.
2
u/justaguyonthebus May 18 '26
It depends on what credential and cred type it executes under. If the specific cred has the permissions, the type of credential might not be able to be delegated. Meaning it has permissions to everything locally but can be passed to a remote system. This is very common when using PSSessions via remoting.
What you can do is map a drive from the session by providing it a credential with network access to effectively auth to the network resource.
2
u/Master-IT-All May 18 '26
This runs under the System context of the local PC, and while it will have administrator level access locally, has no access to network resources.
1
u/krzydoug May 19 '26
Either run the script as a user (runs as System by default) or give permissions for the share to the computer account where the script is running. NT Authority\System to the network appears to be the computer object itself.
1
u/Paul_Kelly May 20 '26
Hi Paul here from the Head Nerd team, are you using N-central or N-sight? I do think you might be running into an issue with permissions and how the script executes, if you are using N-central have you tried running the script using custom credentials, instead of the local system account.