DEV Community

redhcp
redhcp

Posted on • Edited on

2 1

Handler common Activities Tasks VMs

These scripts help reduce execution times and can be done remotely and to multiple VMs at the same time.

Task for handle services,process,scheduletask,etc with powershell

$computers = @(
        'COMPUTER_NAME_1',
        'COMPUTER_NAME_2'
 )
 foreach ($computer in $computers) {

Write-Host "ComputerName: $env:COMPUTERNAME ($(Get-Date -Format MM/dd/yyyy)) "  -foregroundcolor "green"

#STOP PROCESS PID
   #  Invoke-Command -Computername $computer -scriptblock {stop-precess -id 123 } #number PID

#STOP SERVICE
  #  Invoke-Command -Computername $computer -scriptblock {stop-service SERVICE-NAME -force}

#Validate Service 
    # Invoke-Command -Computername $computer -scriptblock {get-service SERVICE-NAME}

#Start Service
    # Invoke-Command -Computername $computer -scriptblock {start-service SERVICE-NAME }

#Disable TASK
    # Invoke-Command -Computername $computer -scriptblock {Disable-ScheduledTask -TaskName TASKNAME}

#Enable TASK
    # Invoke-Command -Computername $computer -scriptblock {Enable-ScheduledTask -TaskName TASKNAME}

#Start TASK
    # Invoke-Command -Computername $computer -scriptblock {Start-ScheduledTask -TaskName TASKNAME}

#VALIDATE TASK
  Invoke-Command -Computername $computer -scriptblock {Get-ScheduledTask -TaskName "TASKNAME"}

#Get TASK by status Values: Running / Ready / Disabled / Queued / Unknown
 #Invoke-Command -Computername $computer -scriptblock {Get-ScheduledTask | where{$_.State -eq "Ready"}}

}

Enter fullscreen mode Exit fullscreen mode

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

Top comments (0)

Billboard image

Deploy and scale your apps on AWS and GCP with a world class developer experience

Coherence makes it easy to set up and maintain cloud infrastructure. Harness the extensibility, compliance and cost efficiency of the cloud.

Learn more