# ===================================================================================
# Reset-AllServers.ps1
# (c) SharePoint Products 2010-2022
# ===================================================================================
param
(
    [Parameter(Mandatory=$false, HelpMessage='-ServiceNames Optional, provide a set of service names to restart.')]
    [Array]$ServiceNames=@("SPTimerV4","SPAdminV4","IISADMIN","W3SVC", "OSearch15")
);

$myWindowsID=[System.Security.Principal.WindowsIdentity]::GetCurrent()
$myWindowsPrincipal=new-object System.Security.Principal.WindowsPrincipal($myWindowsID)
$adminRole=[System.Security.Principal.WindowsBuiltInRole]::Administrator
if ($myWindowsPrincipal.IsInRole($adminRole))
{
	$Host.UI.RawUI.BackgroundColor = "DarkBlue"
	clear-host
} else
{
    $arguments = $myInvocation.MyCommand.Definition;
    Start-Process powershell.exe -Verb RunAs -ArgumentList "-file `"$arguments`"";
    exit;
}
 
$Host.UI.RawUI.WindowTitle = "Resetting SharePoint Services on all SharePoint servers"
$0 = $myInvocation.MyCommand.Definition
$dp0 = [System.IO.Path]::GetDirectoryName($0)
. "$dp0\Functions.ps1"

Load-SharePoint-Powershell

Restart-SharePointServicesOnAllServers $ServiceNames

Pause
