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 7982465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:41:16+00:00 2026-06-04T10:41:16+00:00

I am learning PowerShell and trying to stop IIS on a remote server. I

  • 0

I am learning PowerShell and trying to stop IIS on a remote server.

I am using PowerGUI Script Editor that I started in admin mode.

I have this code

$service = Get-WmiObject Win32_Service -ComputerName 'myserver'  -Filter "Name='IISAdmin'"
$service
$service.StopService();
$service.State

State always comes back as running. I don’t know why it does not stop.

Edit

Error I get when running

Invoke-Command -ComputerName 'myserver' { Stop-Service IISAdmin }

Connecting to remote server failed with the following error message :
The client cannot connect to the destination specified in the request.
Verify that the service on the destination is running and is
accepting requests. Consult the logs and documentation for the
WS-Management service running on the destination, most commonly IIS or
WinRM. If the destination is the WinRM service, run the following
command on the destination to analyze and configure the WinRM service:
“winrm quickconfig”. For more information, see the
about_Remote_Troubleshooting Help topic.

Edit2

I found this and it seems to work. I don’t know how to get the information back from Stop-Service so I had to use the other way to get it to me. If you know how please let me know.

Stop-Service -Force -InputObject $(Get-Service -Computer myserver -Name IISAdmin)
$service = Get-WmiObject Win32_Service -ComputerName 'myserver '  -Filter "Name='IISAdmin'"
$service.State

This works. I don’t understand why. The only thing I can think off is I had to use -Force as it would not stop the server otherwise so maybe that is a reason?

  • 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-04T10:41:17+00:00Added an answer on June 4, 2026 at 10:41 am

    Try using PsExec \Server2 -u Administrator -p somePassword IISReset /STOP

    or using PowerGUI Script Editor

    $service = Get-WmiObject -computer 'ServerA' Win32_Service -Filter "Name='IISAdmin'"
    $service
    $service.InvokeMethod('StopService',$Null)
    $service.State
    

    Try using

    $server = "servername"
    $siteName = "Default Web Site"
    $iis = [ADSI]"IIS://$server/W3SVC"
    $site = $iis.psbase.children | where { $_.keyType -eq "IIsWebServer" -AND
    $_.ServerComment -eq $siteName }
    $site.serverstate=3
    $site.setinfo()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I trying to write a PowerShell script (learning at the same time). I have
I've started learning VBScript because of PowerShell, but I want to know if I
Slowly learning Powershell ... I'm working on a script to query a third party
Before one can get started learning PowerShell , one needs to install it and
I have just started using PowerShell today, and I have an intention list files
I have started learning powershell a couple of days ago, and I couldn't find
I'm early on in my PowerShell learning, and I'm wondering if there are some
Learning a lot in my few years of programming that the best projects are
When learning C# for the first time, I was astonished that they had no
Learning jquery, so please be kind :) Using PHP, I have a table with

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.