Permission denied PS script Issue

Hi,

I’m trying to run a simple script which run on one server but creates a file under a share location. When I run it remotely the script works fine. I’m getting permission denied in Octopus.

New-Item -ItemType file “\sharelocation\sharefolder\test.txt”

$cred = get-credential

Invoke-Command -ComputerName “localhost” -Credential “$cred” -ScriptBlock { New-Item -ItemType file “\sharelocation\sharefolder\test.txt” }

This would work but I need a way to use Octopus Variable for the get-credential property.

Or is it a case of obtaining access to that share for my Octopus account? I take it that’s the account running powershell or is it the local one which would be this according to the logs CurrentUser: NT AUTHORITY\SYSTEM

Hi Daniel,

Thank you for reaching out to us with your Powershell permission query.

The most likely explanation for this is that the user that the script is running as doesn’t have permission to create and/or modify files in that folder. It’s also possible that the file/folder is locked by another process as this can sometimes result in unexpected permission issues.

You can check which user the script is running as by checking which user account the Tentacle is configured to use. The script (and all other child processes started by the Tentacle) will be running as this user. You can find more details on this in our documentation:

Can you please check and confirm that the Tentacle user has permission to create the file and, if it does, that no other processes are locking the file/folder?

Best Regards,

Charles

Hi Charles,

Thanks for the quick response. It was running under a local account. I switched this and it has worked a treat.

Thank you,

Dan

1 Like