Link to home
Start Free TrialLog in
Avatar of creative555
creative555

asked on

question for get-service and resetiis powershell commands

Hello everyone,
I just wanted to ask you if we are doing the most efficient way of resetting IIS and validating services on multiple computers.
 
Is this command could be simplified? We only have two servers where we are resetting IIS and 5 computers where we need to validate and set services.
 
Perhaps what we are doing here is NOT the most efficient process.
 
Let me know. Thank you so much!
 
1. At the elevated PowerShell prompt, run the commands below:
      a. Reset IIS
      $pors = (get-content "f:\software\servers.txt") | select-string "por0"
      Foreach ($por in $pors) {Invoke-command –ComputerName $por –ScriptBlock {iisreset}}

      b. Set all DEV services to Automatic - Running
      $servers = get-content -path "f:\software\servers.txt"
      Foreach ($server in $servers) {Invoke-command –ComputerName $server –ScriptBlock {get-service –displayname *DEV* | set-service –startuptype automatic –status running}}

      c. Validate all DEV services status
      $services = Foreach ($server in $servers) {Invoke-command –ComputerName $server –ScriptBlock {get-service –displayname *adms* | select pscomputername,displayname,status,starttype}}
      $services |format-table -autosize
 
Avatar of J0rtIT
J0rtIT
Flag of Venezuela, Bolivarian Republic of image

ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of creative555
creative555

ASKER

Thank you so much!!