Skip to main content
added 3531 characters in body
Source Link

Here's what I'm trying to run: $SPServer=Get-SPServer | Where {($.Role -isnotlike 'Invalid') and ($

$SPServer=Get-SPServer | Where {($_.Role -isnotlike 'Invalid') and ($_.Status -is 'Online')}

Edit: Here's the correct string.Status -is 'Online')} Thank you Zack.

$SPServers = Get-SPServer | Where-Object { $_.Role -notlike ‘Invalid’ } | Select-Object -ExpandProperty Address

Edit: updated the script with the select string from Zack, as well as some changes to the folder filters to not select the Central Admin folder.

$SPServerWrite-Host =" Get-Content "C:\Tools\QTCServers.txt"                                                                                       

ForEachYou ($Serverare inhere $List)
{because 
$Service=(Get-Serviceyou -ComputerNameneed $Server.ComputerNameto -Namereset $Server.Service)
Stop-Servicethe -InputObjectConfig $ServiceCache -Verbose
$Servicein your SharePoint Farm.WaitForStatus('Stopped','00:00:15')
}
ForEach ($Server in $List)
{
Get-Service -InputObject $Service -Verbose
}   
Start-Sleep -Seconds 2                                                                                   

There are 4 options to choose from.                                                      
                                                                                     

You can run a test to make sure the settings in the script are correct and will          
actually do what they're supposed to do and not delete your whole farm.....          
(I highly suggest you do this first)                                                 
                                                                                     

You can actually do a Reset, and delete the .xml files that are in the config folders.   
                                                                                     

If you forgot something, or something came up, you can Start the timer services back up  
without having to completely exit.                                                   
                                                                                     

Or you can always choose to Stop if you are too chicken to pull the trigger.             
                                                                                     

" -ForegroundColor White -BackgroundColor Red


     
$SPServers = Get-SPServer | Where-Object { $_.Role -notlike ‘Invalid’ } | Select-Object -ExpandProperty Address


do{write-host "Type TEST to " -foregroundcolor Black -backgroundcolor White -nonewline; Write-Host "--TEST--" -foregroundcolor Black -backgroundcolor Green -nonewline; Write-Host "resetting the config cache on all the servers in the farm" -foregroundcolor black -backgroundcolor white
   write-host "Type RESET to " -foregroundcolor Red -backgroundcolor White -NoNewline; Write-Host "!! RESET !!" -ForegroundColor BlackWhite -BackgroundColor Red -NoNewline; Write-Host "the config cache on all the servers in the farm" -foregroundcolor red -backgroundcolor white
   write-host "Type START to start the SharePoint Timer Service on all the servers in the farm" -foregroundcolor black -backgroundcolor white
   write-host "Type STOP if you need to go call your mom." -foregroundcolor whiteBlack -backgroundcolor yellowWhite
    
    $selection = read-host
      if ($selection -eq 'TEST')
        {
        Write-Host "TESTING!!!! Clearing the Config Cache on Farm Servers" -ForegroundColor White -BackgroundColor Green
            Start-Sleep -Seconds 4
            ForEach ($Server$SPServer in $SPServer$SPServers)
              {
                if ( -Not (Test-Path \\$Server\c$\ProgramData\Microsoft\SharePoint\Config\\$SPServer\c$\ProgramData\Microsoft\SharePoint\Config))
                        {
                        Write-Host "Cannot find folder for "\\$Server\c$\Tools\ClearConfigCache"\\$SPServer\c$\Tools\ClearConfigCache
                        }
                else    {
                        Get-ChildItem -Path \\$Server\c$\ProgramData\Microsoft\SharePoint\Config\*\\$SPServer\c$\ProgramData\Microsoft\SharePoint\Config\*.* -Recurse | RemoveWhere-ItemObject {($_.Name -Includene 'cache.ini') -and ($_.FullName -notlike '*00000000-0000-0000-0000-000000000000*') -and ($_.Name -like '*.xml')} -Exclude| '*cache*'Remove-Item -Force -Verbose -WhatIf
                        Get-ChildItem -Path \\$Server\c$\ProgramData\Microsoft\SharePoint\Config\*\\$SPServer\c$\ProgramData\Microsoft\SharePoint\Config\*.* -Recurse | Where-Object {($_.Name -eq 'cache.ini'}) |-and Clear($_.FullName -Contentnotlike '*00000000-Include0000-0000-0000-000000000000*')} 'cache.ini'| Clear-Exclude '*.xml'Content -Force -WhatIf
                        Get-ChildItem -Path \\$Server\c$\ProgramData\Microsoft\SharePoint\Config\*\\$SPServer\c$\ProgramData\Microsoft\SharePoint\Config\*.* -Recurse | Where-Object {($_.Name -eq 'cache.ini') -and ($_.FullName -notlike '*00000000-0000-0000-0000-000000000000*')} | Add-Content -Value "1" -Verbose -WhatIf
                        Write-Host "Cache clear and reset complete on" $Server$SPServer -ForegroundColor White -BackgroundColor Green
                        }
                        {
                        Start-Sleep -Seconds 2
                        }
              }
         }
    elseif ($selection -eq 'RESET')
        {
        Write-Host "Clearing the Config Cache on Farm Servers" -ForegroundColor Red -BackgroundColor Black
            ForEach ($Server in $SPServer$SPServers)
                { 
                $Service=(Get-Service -ComputerName $Server -Name 'SPTimerV4')
                Stop-Service -InputObject $Service -Verbose
                $Service.WaitForStatus('Stopped','00:00:15')
                }
            ForEach ($Server in $SPServers)
                {
                Get-Service -InputObject $Service -Verbose | Format-Table MachineName,Status,Name,DisplayName
                }
            Write-Host "You have about 10 seconds if you want to abort this operation. Press Ctrl+C to stop"
            Start-Sleep -Seconds 10

            ForEach ($Server in $SPServers)
              {
                if ( -Not (Test-Path \\$Server\c$\ProgramData\Microsoft\SharePoint\Config))
                        {
                        Write-Host "Cannot find folder for "\\$Server\c$\ProgramData\Microsoft\SharePoint\Config
                        }
                else    {
                        Get-ChildItem -Path \\$Server\c$\ProgramData\Microsoft\SharePoint\Config\*.* -Recurse | Select Name, FullName | Where-Object {($_.Name -ne 'cache.ini') -and ($_.FullName -notlike '*00000000-0000-0000-0000-000000000000*') -and ($_.Name -like '*.xml')} | Remove-Item -Include '*.xml' -Exclude '*cache*' -Force -Verbose
                        Get-ChildItem -Path \\$Server\c$\ProgramData\Microsoft\SharePoint\Config\*.* -Recurse | Select Name, FullName | Where-Object {($_.Name -eq 'cache.ini'}) |-and Clear($_.FullName -Contentnotlike '*00000000-Include0000-0000-0000-000000000000*')} 'cache.ini'| Clear-Exclude '*.xml'Content -Force
                        Get-ChildItem -Path \\$Server\c$\ProgramData\Microsoft\SharePoint\Config\*.* -Recurse | Select Name, FullName | Where-Object {($_.Name -eq 'cache.ini') -and ($_.FullName -notlike '*00000000-0000-0000-0000-000000000000*')} | Add-Content -Value "1" -Verbose
                        Write-Host "Cache clear and reset complete on" $Server -ForegroundColor White -BackgroundColor Green
                        }
                        {
                        Start-Sleep -Seconds 2
                        }
              }
         }
    elseif ($selection -eq 'START')
         {
        ForEach ($Server in $List$SPServers)
            {
             $Service=(Get-Service -ComputerName $Server.ComputerName -Name $Server.Service'SPTimerV4')
             Start-Service -InputObject $Service -Verbose
             $Service.WaitForStatus('Running','00:00:15')
            }
        ForEach ($Server in $SPServers)
            {
            Get-Service -InputObject $Service -Verbose | Format-Table MachineName,Status,Name,DisplayName
            }
          }
    elseif ($selection -eq 'STOP')
          {
          ForEach ($Server in $List$SPServers)
            {  
            $Service=(Get-Service -ComputerName $Server.ComputerName -Name $Server.Service'SPTimerV4')
            Start-Service $Service -Verbose
            $Service.WaitForStatus('Running','00:00:15')
            }
          ForEach ($Server in $SPServers)
            {
            Get-Service -InputObject $Service -Verbose | Format-Table MachineName,Status,Name,DisplayName
            }
            Write-Host "Fine! Be that way!" -ForegroundColor Black -BackgroundColor White
            Start-Sleep -Seconds 5
          exit
          }
    else
          {
           "Really? You only had 4 choices! How hard was that? You probably need to rethink your life."
           Start-Sleep -Seconds 5
           "Fine....Let's try this again, shall we?"
           Start-Sleep -Seconds 3
          }
  }
Until ($selection -eq 'STOP','RESET')

ForEach ($Server in $List$SPServers)
{  
$Service=(Get-Service -ComputerName $Server.ComputerName -Name $Server.Service'SPTimerV4')
Start-Service -InputObject $Service -Verbose
$Service.WaitForStatus('Running','00:00:15')
}
ForEach ($Server in $List$SPServers)
{
Get-Service -InputObject $Service -Verbose
}
$SPFarmServers.Dispose()
$SPServers.Dispose()
$Server.Dispose()
Write-Host "Thank you for playing, hope it all works out for you!" -foregroundcolor DarkCyan -backgroundcolor Magenta      

Here's what I'm trying to run: $SPServer=Get-SPServer | Where {($.Role -isnotlike 'Invalid') and ($.Status -is 'Online')}

$SPServer = Get-Content "C:\Tools\QTCServers.txt"

ForEach ($Server in $List)
{ 
$Service=(Get-Service -ComputerName $Server.ComputerName -Name $Server.Service)
Stop-Service -InputObject $Service -Verbose
$Service.WaitForStatus('Stopped','00:00:15')
}
ForEach ($Server in $List)
{
Get-Service -InputObject $Service -Verbose
}
Start-Sleep -Seconds 2

do{write-host "Type TEST to " -nonewline; Write-Host "--TEST--" -foregroundcolor Black -backgroundcolor Green -nonewline; Write-Host "resetting the config cache on all the servers in the farm" -foregroundcolor black -backgroundcolor white
   write-host "Type RESET to " -NoNewline; Write-Host "!! RESET !!" -ForegroundColor Black -BackgroundColor Red -NoNewline; Write-Host "the config cache on all the servers in the farm" -foregroundcolor red -backgroundcolor white
   write-host "Type START to start the SharePoint Timer Service on all the servers in the farm" -foregroundcolor black -backgroundcolor white
   write-host "Type STOP if you need to go call your mom." -foregroundcolor white -backgroundcolor yellow
    
    $selection = read-host
      if ($selection -eq 'TEST')
        {
        Write-Host "TESTING!!!! Clearing the Config Cache on Farm Servers" -ForegroundColor White -BackgroundColor Green
            ForEach ($Server in $SPServer)
              {
                if ( -Not (Test-Path \\$Server\c$\ProgramData\Microsoft\SharePoint\Config))
                        {
                        Write-Host "Cannot find folder for "\\$Server\c$\Tools\ClearConfigCache
                        }
                else    {
                        Get-ChildItem -Path \\$Server\c$\ProgramData\Microsoft\SharePoint\Config\*.* -Recurse | Remove-Item -Include '*.xml' -Exclude '*cache*' -Force -Verbose -WhatIf
                        Get-ChildItem -Path \\$Server\c$\ProgramData\Microsoft\SharePoint\Config\*.* -Recurse | Where-Object {$_.Name -eq 'cache.ini'} | Clear-Content -Include 'cache.ini' -Exclude '*.xml' -Force -WhatIf
                        Get-ChildItem -Path \\$Server\c$\ProgramData\Microsoft\SharePoint\Config\*.* -Recurse | Where-Object {$_.Name -eq 'cache.ini'} | Add-Content -Value "1" -Verbose -WhatIf
                        Write-Host "Cache clear and reset complete on" $Server -ForegroundColor White -BackgroundColor Green
                        }
                        {
                        Start-Sleep -Seconds 2
                        }
              }
         }
    elseif ($selection -eq 'RESET')
        {
        Write-Host "Clearing the Config Cache on Farm Servers" -ForegroundColor Red -BackgroundColor Black
            ForEach ($Server in $SPServer)
              {
                if ( -Not (Test-Path \\$Server\c$\ProgramData\Microsoft\SharePoint\Config))
                        {
                        Write-Host "Cannot find folder for "\\$Server\c$\ProgramData\Microsoft\SharePoint\Config
                        }
                else    {
                        Get-ChildItem -Path \\$Server\c$\ProgramData\Microsoft\SharePoint\Config\*.* -Recurse | Remove-Item -Include '*.xml' -Exclude '*cache*' -Force -Verbose
                        Get-ChildItem -Path \\$Server\c$\ProgramData\Microsoft\SharePoint\Config\*.* -Recurse | Where-Object {$_.Name -eq 'cache.ini'} | Clear-Content -Include 'cache.ini' -Exclude '*.xml' -Force
                        Get-ChildItem -Path \\$Server\c$\ProgramData\Microsoft\SharePoint\Config\*.* -Recurse | Where-Object {$_.Name -eq 'cache.ini'} | Add-Content -Value "1" -Verbose
                        Write-Host "Cache clear and reset complete on" $Server -ForegroundColor White -BackgroundColor Green
                        }
                        {
                        Start-Sleep -Seconds 2
                        }
              }
         }
    elseif ($selection -eq 'START')
         {
        ForEach ($Server in $List)
            {
             $Service=(Get-Service -ComputerName $Server.ComputerName -Name $Server.Service)
             Start-Service -InputObject $Service -Verbose
             $Service.WaitForStatus('Running','00:00:15')
            }
          }
    elseif ($selection -eq 'STOP')
          {
          ForEach ($Server in $List)
            {  
            $Service=(Get-Service -ComputerName $Server.ComputerName -Name $Server.Service)
            Start-Service $Service -Verbose
            $Service.WaitForStatus('Running','00:00:15')
            }
           exit
          }
    else
          {
           "Really? You only had 4 choices!How was that? You probably need to rethink your life."
           Start-Sleep -Seconds 5
           "Fine....Let's try this again, shall we?"
           Start-Sleep -Seconds 3
          }
  }
Until ($selection -eq 'STOP','RESET')

ForEach ($Server in $List)
{  
$Service=(Get-Service -ComputerName $Server.ComputerName -Name $Server.Service)
Start-Service -InputObject $Service -Verbose
$Service.WaitForStatus('Running','00:00:15')
}
ForEach ($Server in $List)
{
Get-Service -InputObject $Service -Verbose
}
Write-Host "Thank you for playing, hope it all works out for you!" -foregroundcolor DarkCyan -backgroundcolor Magenta      

Here's what I'm trying to run:

$SPServer=Get-SPServer | Where {($_.Role -isnotlike 'Invalid') and ($_.Status -is 'Online')}

Edit: Here's the correct string. Thank you Zack.

$SPServers = Get-SPServer | Where-Object { $_.Role -notlike ‘Invalid’ } | Select-Object -ExpandProperty Address

Edit: updated the script with the select string from Zack, as well as some changes to the folder filters to not select the Central Admin folder.

Write-Host "                                                                                         

You are here because you need to reset the Config Cache in your SharePoint Farm.         
                                                                                     

There are 4 options to choose from.                                                      
                                                                                     

You can run a test to make sure the settings in the script are correct and will          
actually do what they're supposed to do and not delete your whole farm.....          
(I highly suggest you do this first)                                                 
                                                                                     

You can actually do a Reset, and delete the .xml files that are in the config folders.   
                                                                                     

If you forgot something, or something came up, you can Start the timer services back up  
without having to completely exit.                                                   
                                                                                     

Or you can always choose to Stop if you are too chicken to pull the trigger.             
                                                                                     

" -ForegroundColor White -BackgroundColor Red


     
$SPServers = Get-SPServer | Where-Object { $_.Role -notlike ‘Invalid’ } | Select-Object -ExpandProperty Address


do{write-host "Type TEST to " -foregroundcolor Black -backgroundcolor White -nonewline; Write-Host "--TEST--" -foregroundcolor Black -backgroundcolor Green -nonewline; Write-Host "resetting the config cache on all the servers in the farm" -foregroundcolor black -backgroundcolor white
   write-host "Type RESET to " -foregroundcolor Red -backgroundcolor White -NoNewline; Write-Host "!! RESET !!" -ForegroundColor White -BackgroundColor Red -NoNewline; Write-Host "the config cache on all the servers in the farm" -foregroundcolor red -backgroundcolor white
   write-host "Type START to start the SharePoint Timer Service on all the servers in the farm" -foregroundcolor black -backgroundcolor white
   write-host "Type STOP if you need to go call your mom." -foregroundcolor Black -backgroundcolor White
    
    $selection = read-host
      if ($selection -eq 'TEST')
        {
        Write-Host "TESTING!!!! Clearing the Config Cache on Farm Servers" -ForegroundColor White -BackgroundColor Green
            Start-Sleep -Seconds 4
            ForEach ($SPServer in $SPServers)
              {
                if ( -Not (Test-Path \\$SPServer\c$\ProgramData\Microsoft\SharePoint\Config))
                        {
                        Write-Host "Cannot find folder for "\\$SPServer\c$\Tools\ClearConfigCache
                        }
                else    {
                        Get-ChildItem -Path \\$SPServer\c$\ProgramData\Microsoft\SharePoint\Config\*.* -Recurse | Where-Object {($_.Name -ne 'cache.ini') -and ($_.FullName -notlike '*00000000-0000-0000-0000-000000000000*') -and ($_.Name -like '*.xml')} | Remove-Item -Force -Verbose -WhatIf
                        Get-ChildItem -Path \\$SPServer\c$\ProgramData\Microsoft\SharePoint\Config\*.* -Recurse | Where-Object {($_.Name -eq 'cache.ini') -and ($_.FullName -notlike '*00000000-0000-0000-0000-000000000000*')} | Clear-Content -Force -WhatIf
                        Get-ChildItem -Path \\$SPServer\c$\ProgramData\Microsoft\SharePoint\Config\*.* -Recurse | Where-Object {($_.Name -eq 'cache.ini') -and ($_.FullName -notlike '*00000000-0000-0000-0000-000000000000*')} | Add-Content -Value "1" -Verbose -WhatIf
                        Write-Host "Cache clear and reset complete on" $SPServer -ForegroundColor White -BackgroundColor Green
                        }
                        {
                        Start-Sleep -Seconds 2
                        }
              }
         }
    elseif ($selection -eq 'RESET')
        {
        Write-Host "Clearing the Config Cache on Farm Servers" -ForegroundColor Red -BackgroundColor Black
            ForEach ($Server in $SPServers)
                { 
                $Service=(Get-Service -ComputerName $Server -Name 'SPTimerV4')
                Stop-Service -InputObject $Service -Verbose
                $Service.WaitForStatus('Stopped','00:00:15')
                }
            ForEach ($Server in $SPServers)
                {
                Get-Service -InputObject $Service -Verbose | Format-Table MachineName,Status,Name,DisplayName
                }
            Write-Host "You have about 10 seconds if you want to abort this operation. Press Ctrl+C to stop"
            Start-Sleep -Seconds 10

            ForEach ($Server in $SPServers)
              {
                if ( -Not (Test-Path \\$Server\c$\ProgramData\Microsoft\SharePoint\Config))
                        {
                        Write-Host "Cannot find folder for "\\$Server\c$\ProgramData\Microsoft\SharePoint\Config
                        }
                else    {
                        Get-ChildItem -Path \\$Server\c$\ProgramData\Microsoft\SharePoint\Config\*.* -Recurse | Select Name, FullName | Where-Object {($_.Name -ne 'cache.ini') -and ($_.FullName -notlike '*00000000-0000-0000-0000-000000000000*') -and ($_.Name -like '*.xml')} | Remove-Item -Include '*.xml' -Exclude '*cache*' -Force
                        Get-ChildItem -Path \\$Server\c$\ProgramData\Microsoft\SharePoint\Config\*.* -Recurse | Select Name, FullName | Where-Object {($_.Name -eq 'cache.ini') -and ($_.FullName -notlike '*00000000-0000-0000-0000-000000000000*')} | Clear-Content -Force
                        Get-ChildItem -Path \\$Server\c$\ProgramData\Microsoft\SharePoint\Config\*.* -Recurse | Select Name, FullName | Where-Object {($_.Name -eq 'cache.ini') -and ($_.FullName -notlike '*00000000-0000-0000-0000-000000000000*')} | Add-Content -Value "1" -Verbose
                        Write-Host "Cache clear and reset complete on" $Server -ForegroundColor White -BackgroundColor Green
                        }
                        {
                        Start-Sleep -Seconds 2
                        }
              }
         }
    elseif ($selection -eq 'START')
         {
        ForEach ($Server in $SPServers)
            {
             $Service=(Get-Service -ComputerName $Server -Name 'SPTimerV4')
             Start-Service -InputObject $Service -Verbose
             $Service.WaitForStatus('Running','00:00:15')
            }
        ForEach ($Server in $SPServers)
            {
            Get-Service -InputObject $Service -Verbose | Format-Table MachineName,Status,Name,DisplayName
            }
          }
    elseif ($selection -eq 'STOP')
          {
          ForEach ($Server in $SPServers)
            {  
            $Service=(Get-Service -ComputerName $Server -Name 'SPTimerV4')
            Start-Service $Service -Verbose
            $Service.WaitForStatus('Running','00:00:15')
            }
          ForEach ($Server in $SPServers)
            {
            Get-Service -InputObject $Service -Verbose | Format-Table MachineName,Status,Name,DisplayName
            }
            Write-Host "Fine! Be that way!" -ForegroundColor Black -BackgroundColor White
            Start-Sleep -Seconds 5
          exit
          }
    else
          {
           "Really? You only had 4 choices! How hard was that? You probably need to rethink your life."
           Start-Sleep -Seconds 5
           "Fine....Let's try this again, shall we?"
           Start-Sleep -Seconds 3
          }
  }
Until ($selection -eq 'STOP','RESET')

ForEach ($Server in $SPServers)
{  
$Service=(Get-Service -ComputerName $Server -Name 'SPTimerV4')
Start-Service -InputObject $Service -Verbose
$Service.WaitForStatus('Running','00:00:15')
}
ForEach ($Server in $SPServers)
{
Get-Service -InputObject $Service -Verbose
}
$SPFarmServers.Dispose()
$SPServers.Dispose()
$Server.Dispose()
Write-Host "Thank you for playing, hope it all works out for you!" -foregroundcolor DarkCyan -backgroundcolor Magenta
Source Link

Get the servers in the farm and place in UNC path (Reset Config Cache)

I'm trying to be fancy and create an script that other people on my team can use to reset the Config Cache in our SharePoint 2016 farm. This is sometimes necessary if we change anything around our Nintex Workflows or their databases. The settings really like to stick around.

I can get the script to work fine if I have a list of the servers and just use Get-Content and pipe that in to the UNC path where the config files are located. But if I try to keep the script more dynamic and use Get-SPServer, it puts in more information that just the server name.

Here's what I'm trying to run: $SPServer=Get-SPServer | Where {($.Role -isnotlike 'Invalid') and ($.Status -is 'Online')}

Then put that into a UNC path to loop through all the servers in the farm:

$selection = read-host

      if ($selection -eq 'TEST')
        {
        Write-Host "TESTING!!!! Clearing the Config Cache on Farm Servers" -ForegroundColor White -BackgroundColor Green
            ForEach ($Server in $SPServer)
              {
                if ( -Not (Test-Path **\\$Server\c$\ProgramData\Microsoft\SharePoint\Config**))
                        {
                        Write-Host "Cannot find folder for "\\$Server\c$\Tools\ClearConfigCache
                        }
                else    {
                        Get-ChildItem -Path \\$Server\c$\ProgramData\Microsoft\SharePoint\Config\*.* -Recurse | Remove-Item -Include '*.xml' -Exclude '*cache*' -Force -Verbose -WhatIf
                        Get-ChildItem -Path \\$Server\c$\ProgramData\Microsoft\SharePoint\Config\*.* -Recurse | Where-Object {$_.Name -eq 'cache.ini'} | Clear-Content -Include 'cache.ini' -Exclude '*.xml' -Force -WhatIf
                        Get-ChildItem -Path \\$Server\c$\ProgramData\Microsoft\SharePoint\Config\*.* -Recurse | Where-Object {$_.Name -eq 'cache.ini'} | Add-Content -Value "1" -Verbose -WhatIf
                        Write-Host "Cache clear and reset complete on" $Server -ForegroundColor White -BackgroundColor Green
                        }
                        {
                        Start-Sleep -Seconds 2
                        }
              }
         }

The Test-Path causes it to fail and returns the path "\SPServer Name=[Whateverserver]\c$\ProgramData\Microsoft\SharePoint\Config

The same variable, though, works fine when I use it to stop the services.

ForEach ($Server in $SPServer)
            {
             $Service=(Get-Service -ComputerName $Server -Name SPTimerV4)
             Start-Service -InputObject $Service -Verbose
             $Service.WaitForStatus('Running','00:00:15')
            }

I don't want to have to use a list for this, there's go to be a way to just input the actual server name for that variable. Below is my full script, in case anyone else has a need for this as well.

$SPServer = Get-Content "C:\Tools\QTCServers.txt"

ForEach ($Server in $List)
{ 
$Service=(Get-Service -ComputerName $Server.ComputerName -Name $Server.Service)
Stop-Service -InputObject $Service -Verbose
$Service.WaitForStatus('Stopped','00:00:15')
}
ForEach ($Server in $List)
{
Get-Service -InputObject $Service -Verbose
}
Start-Sleep -Seconds 2

do{write-host "Type TEST to " -nonewline; Write-Host "--TEST--" -foregroundcolor Black -backgroundcolor Green -nonewline; Write-Host "resetting the config cache on all the servers in the farm" -foregroundcolor black -backgroundcolor white
   write-host "Type RESET to " -NoNewline; Write-Host "!! RESET !!" -ForegroundColor Black -BackgroundColor Red -NoNewline; Write-Host "the config cache on all the servers in the farm" -foregroundcolor red -backgroundcolor white
   write-host "Type START to start the SharePoint Timer Service on all the servers in the farm" -foregroundcolor black -backgroundcolor white
   write-host "Type STOP if you need to go call your mom." -foregroundcolor white -backgroundcolor yellow
    
    $selection = read-host
      if ($selection -eq 'TEST')
        {
        Write-Host "TESTING!!!! Clearing the Config Cache on Farm Servers" -ForegroundColor White -BackgroundColor Green
            ForEach ($Server in $SPServer)
              {
                if ( -Not (Test-Path \\$Server\c$\ProgramData\Microsoft\SharePoint\Config))
                        {
                        Write-Host "Cannot find folder for "\\$Server\c$\Tools\ClearConfigCache
                        }
                else    {
                        Get-ChildItem -Path \\$Server\c$\ProgramData\Microsoft\SharePoint\Config\*.* -Recurse | Remove-Item -Include '*.xml' -Exclude '*cache*' -Force -Verbose -WhatIf
                        Get-ChildItem -Path \\$Server\c$\ProgramData\Microsoft\SharePoint\Config\*.* -Recurse | Where-Object {$_.Name -eq 'cache.ini'} | Clear-Content -Include 'cache.ini' -Exclude '*.xml' -Force -WhatIf
                        Get-ChildItem -Path \\$Server\c$\ProgramData\Microsoft\SharePoint\Config\*.* -Recurse | Where-Object {$_.Name -eq 'cache.ini'} | Add-Content -Value "1" -Verbose -WhatIf
                        Write-Host "Cache clear and reset complete on" $Server -ForegroundColor White -BackgroundColor Green
                        }
                        {
                        Start-Sleep -Seconds 2
                        }
              }
         }
    elseif ($selection -eq 'RESET')
        {
        Write-Host "Clearing the Config Cache on Farm Servers" -ForegroundColor Red -BackgroundColor Black
            ForEach ($Server in $SPServer)
              {
                if ( -Not (Test-Path \\$Server\c$\ProgramData\Microsoft\SharePoint\Config))
                        {
                        Write-Host "Cannot find folder for "\\$Server\c$\ProgramData\Microsoft\SharePoint\Config
                        }
                else    {
                        Get-ChildItem -Path \\$Server\c$\ProgramData\Microsoft\SharePoint\Config\*.* -Recurse | Remove-Item -Include '*.xml' -Exclude '*cache*' -Force -Verbose
                        Get-ChildItem -Path \\$Server\c$\ProgramData\Microsoft\SharePoint\Config\*.* -Recurse | Where-Object {$_.Name -eq 'cache.ini'} | Clear-Content -Include 'cache.ini' -Exclude '*.xml' -Force
                        Get-ChildItem -Path \\$Server\c$\ProgramData\Microsoft\SharePoint\Config\*.* -Recurse | Where-Object {$_.Name -eq 'cache.ini'} | Add-Content -Value "1" -Verbose
                        Write-Host "Cache clear and reset complete on" $Server -ForegroundColor White -BackgroundColor Green
                        }
                        {
                        Start-Sleep -Seconds 2
                        }
              }
         }
    elseif ($selection -eq 'START')
         {
        ForEach ($Server in $List)
            {
             $Service=(Get-Service -ComputerName $Server.ComputerName -Name $Server.Service)
             Start-Service -InputObject $Service -Verbose
             $Service.WaitForStatus('Running','00:00:15')
            }
          }
    elseif ($selection -eq 'STOP')
          {
          ForEach ($Server in $List)
            {  
            $Service=(Get-Service -ComputerName $Server.ComputerName -Name $Server.Service)
            Start-Service $Service -Verbose
            $Service.WaitForStatus('Running','00:00:15')
            }
           exit
          }
    else
          {
           "Really? You only had 4 choices!How was that? You probably need to rethink your life."
           Start-Sleep -Seconds 5
           "Fine....Let's try this again, shall we?"
           Start-Sleep -Seconds 3
          }
  }
Until ($selection -eq 'STOP','RESET')

ForEach ($Server in $List)
{  
$Service=(Get-Service -ComputerName $Server.ComputerName -Name $Server.Service)
Start-Service -InputObject $Service -Verbose
$Service.WaitForStatus('Running','00:00:15')
}
ForEach ($Server in $List)
{
Get-Service -InputObject $Service -Verbose
}
Write-Host "Thank you for playing, hope it all works out for you!" -foregroundcolor DarkCyan -backgroundcolor Magenta