Script execution stops in the middle after Stop-Service cmdlet+PRTG

Welcome Forums General PowerShell Q&A Script execution stops in the middle after Stop-Service cmdlet+PRTG

Viewing 2 reply threads
  • Author
    Posts
    • #273708
      Participant
      Topics: 1
      Replies: 1
      Points: 13
      Rank: Member

      Hello
      I’m setting up PS script which is to stop&start Windows service, copy and rename log file. This is script is run by the PRTG application (monitoring solution) when certain conditions are met. The script is executed by the platform on the platform server and makes mentioned changes on the remote computer. The problem that we have is that script execution stops once ‘Stop-Service’ is executed but there are still few lines to cover. There doesn’t seem to be any error or whatever. When I remove the ‘Stop-Service’ from the script then the full script is executed.
      What I need to mention about is that the issue only is when this script is run by PRTG but when I run the script manually on the servers it works just fine. I’ve tried different variations of the script but the script is always stopping whenever it finishes the ‘Stop-Service’ execution.
      At first glance it may look like user related issue (PRTG uses the same admin credts to start the script as when script is run manually) however the script itself runs. Do you know what might be the issue here? Please find below script lines that I use.
      I’ll much appreciate your thoughts about it as I’ve spent much time troubleshooting it 😉

      Kind regards,
      Karol

      • This topic was modified 1 month, 3 weeks ago by karwie60.
      • This topic was modified 1 month, 3 weeks ago by grokkit.
    • #273711
      Participant
      Topics: 1
      Replies: 1
      Points: 13
      Rank: Member

      I forgot to add one more thing. When ‘Stop-Service’ is successfully executed then the ‘Move-Item’ doesn’t provide any output to the log1.txt. File isn’t even created a that stage.

      Kind regards,
      Karol

    • #273720
      Participant
      Topics: 17
      Replies: 1951
      Points: 3,988
      Helping Hand
      Rank: Community Hero

      karwie60, welcome to Powershell.org. Please take a moment and read the very first post on top of the list of this forum: Read Me Before Posting! You’ll be Glad You Did!.

      When you post code, error messages, sample data or console output format it as code, please.
      In the “Text” view you can use the code tags “CRAYON“, in the “Visual” view you can use the format template “Preformatted“. You can go back edit your post and fix the formatting – you don’t have to create a new one.
      Thanks in advance.

      My DOS is rusty. What is this ‘3>&1 2>&1’ redirection doing?

      • This reply was modified 1 month, 3 weeks ago by Rob Simmers.
Viewing 2 reply threads
  • You must be logged in to reply to this topic.