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 Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

Top comments (0)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay