Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8624385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:31:04+00:00 2026-06-12T07:31:04+00:00

We have a few home-brewed windows services over here. One of them is problematic,

  • 0

We have a few home-brewed windows services over here. One of them is problematic, in that it won’t always stop when asked. It gets stuck in the ‘Stopping’ state sometimes.

Using powershell we’re retrieving its PID and using the Stop-Process cmdlet to kill the related process, but that’s not working either.

Instead we get a message about a service named System.ServiceProcess.ServiceController.Name which obviously isn’t our service, but the PID it references is.

Here’s what we’re doing to get our service to stop. First, we use the Get-Service cmdlet:

$ServiceNamePID = Get-Service -ComputerName $Computer | where { ($_.Status -eq 'StopPending' -or $_.Status -eq 'Stopping') -and $_.Name -eq $ServiceName}

Then, with that ServiceNamePID, we get the PID and use that in the Stop-Process cmdlet

$ServicePID = (get-wmiobject win32_Service -ComputerName $Computer | Where { $_.Name -eq $ServiceNamePID.Name }).ProcessID
Stop-Process $ServicePID -force

That’s when the Stop-Process cmdlet squawks about Cannot find a process with the process identifier XYZ, when in fact PID XYZ is the correct Process ID for the service, per the task manager. Has anyone seen a problem like this before?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T07:31:06+00:00Added an answer on June 12, 2026 at 7:31 am

    In order to stop a process on a remote machine, use remoting e.g.

     Invoke-Command -cn $compName {param($pid) Stop-Process -Id $pid -force } -Arg $ServicePID
    

    This requires remoting to be enabled on the remote PC and the local account has admin price on the remote PC.

    Of course, once you’re using remoting you could do the script using remoting e.g.:

    Invoke-Command -cn $compName {
        $ServiceName = '...'
        $ServiceNamePID = Get-Service | Where {($_.Status -eq 'StopPending' -or $_.Status -eq 'Stopping') -and $_.Name -eq $ServiceName}
        $ServicePID = (Get-WmiObject Win32_Service | Where {$_.Name -eq $ServiceNamePID.Name}).ProcessID
        Stop-Process $ServicePID -Force
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I had a home page which have a few tables that refresh itself every
I have a few domain aliases, while I only want one of them to
I have a few areas in my application that are relatively independent (all navigated
Here's the scenario: At work we have quite a few branches and we haven't
I have a few rotating videos on a home page. The first video shows
I have a few div boxes that are using position:fixed and I use a
I have created a few home screen widgets for my Android application. I would
I have few XSLT files, index stylesheet imports layout using xsl:import. VS says that
Greetings , I have a few questions that need experts' help to demystify it.
I have used few Jqueries on my home page for sliding Images, Tabs and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.