Kaseya Community

Stopping and Starting a Service via Powershell - Hangs

  • Hi ya'll - 

    I'm simply trying to execute a Powershell script to Stop and then Start the googledrivesync program to force a synchronization. I've tried executing the following both as executePowershellCommand64BitUser and executePowerhsellCommand64BitSystem. I just wanted to start with the Stop-Process first:

    Stop-Process -name "googledrivesync"

    The Agent Procedure isn't failing and it's not completing - it just seems to have gotten hung up and I'm not sure why. 

    Any ideas on how to get this executing properly? I know the syntax itself is ok because I tested that in local Powershell and got the behavior I expected to see.

    Thanks in advance! 

  • Try live connect and run the PS command in the command prompt after starting PS - does it work there? Any unusual output or issues that don't occur when you're logged in to the console?

    Have you tried a simple net stop ; net start or even the procedure commands for service control? What's PS giving you that the basic tools aren't?


  • Hey gbarnas thanks for the response. I can run everything just fine using the Powershell drop down from the command line and it executes and stops the service BUT it did throw a prompt I didn't see when running locally


    Are you sure you want to perform the Stop-Process operation on the following item: GoogleDriveFS(824)?

    Yes Yes  Angel Yes to All  No No  [L] No to All  Sleep Suspend  [?] Help (default is "Y"): a

    Is there an argument I need to pass? Would it just be a?

    I can't seem to find the service behind Google File Stream - there's just a process from what I can tell so I'd rather Start-Process Stop-Process to force a resync.

  • Have you considered just using the stop/start service command arleady provided in agent procedures. It would be easier to troubleshoot if something does go wrong.

  • You can add in -Force and -Confirm:$false to both have it not ask and to stop the process if it is owned by a user other than the one running the cmdlet.

    Stop-Process -Name "googledrivesync" -Force -Confirm:$false

  • Hi Redfined;

    I got your message, its going to be hard for me to help you with specifics as I don't have access to a Kaseya server any more to test my ideas before I suggest them. Unfortunately not a lot of companies are looking for Kaseya Admins anymore in the area where I live and I can't afford to move :(

    From what you have posted it looks like you need to add " -Force" to force the stop-process command and bypass the confirmation request by doing something like this;

    Stop-Process -name "googledrivesync" -Force

    Note that this command that you are using is killing the Process and not stopping the Service, if the service is configured for Auto Start it could auto restart the Process so you need to find out what the Service name is and use one of the following command example to stop the service it self;

    Stop-Service -name "googledrivesync" -Force

    (note to start the service use the following command without the -Force:

    Start-Service -name "googledrivesync")

    this command should also work;

    Get-Service -Name "googledrivesync" | Set-Service -Status stopped

    to undo it and star the service use this command

    Get-Service -Name "googledrivesync" | Set-Service -Status running

    It is good practice to stop both the service and to kill the process for in case the service is just there to keep the process alive as stopping service does not alway stop the related process.

    Goodluck and I hope that made sense and that it helps.

    [edited by: HardKnoX at 7:07 AM (GMT -7) on Apr 8, 2018]
  • Thanks the adding -force at the end of the command worked. Super confused because when I start the process again the process starts but there's no GUI. I think this might have to do with the script not running as the current user perhaps. I started a new thread for that though.So much fun! <insert sarcasm here>

  • I don't see the Google Drive Sync in services so I'm thinking that perhaps there's not a service behind it so I'm not sure how this would work out. Thanks for the response though.

  • I noticed that you referred to it as Service in the post subject so I thought just to be thorough I would provide examples on how to stop both a process and a service.

    Regarding not seeing the GUI of the googledrive process, when you start the google drive process with the agent procedure it will depend on what user you run the command as.