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


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: (:) [], 
+ FullyQualifiedErrorId : NativeCommandFailed

Any thoughts / suggestions are greatly appreciated!

  • Hate to break it but it is a credentials issue. Can you run procmon on that server and execute your script again? – Lieven Keersmaekers May 12 '17 at 14:12
  • If I run it locally on the server, it runs fine. I'll try the procmon route though. – mosaic3 May 12 '17 at 14:24
  • Ah, misunderstanding. I meant "run procmon on that server and execute your script from your workstation again" – Lieven Keersmaekers May 12 '17 at 17:01
  • Yep, all clear @Lieven Keersmaekers. I ran procmon and it looks like the denies are occurring on the create requests. – mosaic3 May 12 '17 at 17:20
  • 1
    If you doubleclick the event, you can get the user executing the process in the Process tab. That user doesn't have permissions to nsrports.exe. – Lieven Keersmaekers May 12 '17 at 20:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.