asked on
{
#Define Variables
$ComputerName = $WorkstationNameTextBox.Text
$Credentials = $ServiceIDTextBox.Text
$ServiceName = [ToString]$ServiceNameTextBox.Text
#create session and set startup type
$s = New-PSSession -ComputerName $ComputerName -Credential $Credentials
Invoke-Command -Session $s -ScriptBlock {Set-Service -Name $ServiceName -StartupType Automatic
#changing the Failure options
sc.exe failure $ServiceName actions = restart/60000/restart/60000/restart/60000 reset= 86400;
#Restart service
Restart-Service -Name $ServiceName -Force -ErrorAction Stop}
Windows PowerShell is a task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language built on the .NET Framework. PowerShell provides full access to the Component Object Model (COM) and Windows Management Instrumentation (WMI), enabling administrators to perform administrative tasks on both local and remote Windows systems as well as WS-Management and Common Information Model (CIM) enabling management of remote Linux systems and network devices.
TRUSTED BY
ASKER