I have two servers Server A and Server B. I want to stop server A from Server B remotely using Powershell script.
相关问题
- How to Debug/Register a Permanent WMI Event Which
- How can I do variable substitution in a here-strin
- How to use a default value with parameter sets in
- Does powershell have a method_missing()?
- How to make a .svc file write to asp.net Trace.axd
Because you asked for Powershell:
Agreed this question should be moved to ServerFault.
Option 1:
Option 2:
Option 3:
In powershell 2.0, run the following from cmd prompt:
One of the simplest ways to do this is really with just a command line execution using PsExec. And send over to the machines
IISReset /STOP or /START or /RESTART
So you'd do something like this
Just be careful with password management if you go this route or any route that involves some type of admin level account impersonation so that no one can get a plain text copy of the admin password.
You can use get-wmiobject cmdlt with different NameSpace for different versions of IIS v6 or v7, below pipelining command can be used for such operations in IIS locally or remotely
for IIS v6
you need to have sufficient account privilege for these operations, event though i prefer to do $x.Recycle() for my websites.