Networking/Restart-Wall.ps1

<#
    .NOTES
    ===========================================================================
     Created with: SAPIEN Technologies, Inc., PowerShell Studio 2019 v5.6.156
     Created on: 1/18/2019 08:08
     Created by: jisodl0
     Organization: J.B. Hunt
     Filename: Restart-Wall.ps1
    ===========================================================================
    .DESCRIPTION
        A script used for restarting/updating the computers responsible for the NOC
    wall of screens.
#>


<#
  .SYNOPSIS
    Restarts the machines responsible for the NOC wall displays.
  
  .DESCRIPTION
    Restarts the machines/servers responsible for the NOC dashboards displayed on the wall. Each server is stopped before moving on to the next.
  
  .EXAMPLE
    PS C:\> Restart-Wall

  .EXAMPLE
    PS C:\> rsw
#>

function Restart-Wall {
  [CmdletBinding(ConfirmImpact = 'Medium')]
  [Alias('rsw')]
  param ()
  
  BEGIN {
    try {
      $Servers = Get-Content "\\jbhunt.sharepoint.com@SSL\DavWWWRoot\sites\IOCCNOC\Shared Documents\NOC Documents\Video Wall\Restart Script (DON'T DELETE)\servers.txt"
    } catch {
      Write-Error 'An error occurred while trying to get the server list...'
      Write-Error $_
    }
  }
  
  PROCESS {
    try {
      $Servers | ForEach-Object {
        Restart-Computer -ComputerName $_ -Force -Wait
        Get-Service -Name CmRcService -ComputerName $_ | Start-Service
        Start-Process "C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\i386\CmRCViewer.exe" $_
      }
    } catch {
      Write-Error 'An error occurred while trying to restart the computers...'
      Write-Error $_
    }
  }
  
  END { Write-Host 'The wall servers have been restarted.' }
}