PowerShell Instance Summary (service management)

Source: Internet
Author: User

The specific instance scripts for service management are as follows:

#$lists = "1.1.1.1", "2.2.2.2" #远程ip列表foreach($list inch $lists){    $uname=' abc '$PWD=convertto-securestring"DEFGH"-asplaintext- Force$cred= New-object System. Management.Automation.PSCredential ($uname,$PWD) Write-output"***************************************"Write-output"*************"$list"*************"Write-output"***************************************"Invoke-command-computername$list-Command {#get-service |where {$_. Name-contains ' MSIServer '}| stop-service-passthru| Set-service-startuptype Disabled    #Get-wmiobject Win32_Service | where {$_. Name-contains ' MSIServer '}    #get-service |where {$_. Name-contains ' MSIServer '}| Set-service-startuptype Disabled    #get-service |where {$_. Name-contains ' MSIServer '}| Start-service-passthruGet-wmiobject Win32_Service | where {$_. Name-contains' MSIServer '}#get-service |where {$_. Name-contains ' CLUSSVC '}        #get-service |where {$_. Name-contains ' CLUSSVC '}|set-service-startuptype Automatic |start-service        #get-service |where {$_. Name-contains ' MSSQLSERVER '}}-credential$cred}

The relevant comments for the above script are as follows:

#View the health status and properties of a specific serviceGet-wmiobject Win32_Service | where {$_. Name-contains' MSIServer '}#properties and run StateGet-service |where {$_. Name-contains' MSIServer '}#Run Status and description name#Open ServiceGet-service |where {$_. Name-contains' MSIServer '}| Start-service-PassThru#Turn off service # restart restartGet-service |where {$_. Name-contains' MSIServer '}| Stop-service-PassThru#Changing service PropertiesGet-service |where {$_. Name-contains' MSIServer '}| Set-service-startuptype Disabled#where the Startup type has Automatic Disabled Manual

Problems that you may encounter when you use PowerShell to remotely administer a server:

The network can not connect to the Red fork, still be able to surf the internet, this small probability event is due to Windows in the run error will make the system services become unstable and error can not self-restart repair caused by the general need CMD (that is, DOS mode) instructions to restart the project service group is good, must use administrator rights, Recommended to turn off all protection software

net localgroup Administrators LocalService//add

#网络连接模式 can't be a public network
#开启powershell远程管理

Enable-psremoting-force

# Add Trust IP List

Set-item wsman:\localhost\client\trustedhosts *-force

Error in adding the list of trusted IPs, can refer to the link http://www.cnblogs.com/dreamer-fish/archive/2013/03/15/2961497.html

PowerShell Instance Summary (service management)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.