Networking/Restart-Wall.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<#
    .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.' }
}