I'm trying to execute the following script on several remote servers and I think the syntax is correct, but it keeps coming back as "access denied". A few things to note - I am executing the script as an admin on the destination boxes, so creds shouldn't be an issue. I also tried using -cred just in case and the same error occurs.
Essentially what the script is trying to do is execute the nsrports command from that static location and change the port range, then recycle the networker service.
$servers = Get-Content Z:\scripts\computers2.txt
invoke-command -ComputerName $servers -ScriptBlock {cd "C:\Program
Files\Legato\nsr\bin\"; .\nsrports -s "7937-9000"}
Restart-service -DisplayName "*Networker Remote Display Service" -force
Output:
Program 'nsrports.exe' failed to execute: Access is denied
At line:1 char:50
+ cd "C:\Program Files\Legato\nsr\bin\"; .\nsrports <<<< -s "7937-9000".
+ CategoryInfo : ResourceUnavailable: (:) [],
ApplicationFailedException
+ FullyQualifiedErrorId : NativeCommandFailed
Any thoughts / suggestions are greatly appreciated!