IWEUA.COM
Starting / Stopping
Hyperdecks with
powershell
November 2020

Entire and full credit to Ian Morrish for these scripts,  who's Git posting is HERE

Ian's more complete blog is here ( Nov 2020 ) is HERE

And IAN's link to his Powershell notes are HERE which included the link to ATEM SwitcherLib.dll

I tweaked the code a little to start Hyperdecks running in record and to quit the script.
My Engineers were a little nervous having the original script running as multiple machines were in record, waiting
for a 'q' to stop them.

I created a new script which
has to be run ( in a new tab of Powershell ) call STOP to stop the machines.

Each of the IP addresses corresponds to the File name, th
us 10.10.161.31, records a filename
'TX_ddmmyy_hhmmss'

If you have not used Powershell before you will need to ensure that scripts are enabled by running Powershell in


Administrator mode :
enter command :
Set-ExecutionPolicy RemoteSigned
Say YES
Restart Powershell
Ensure the command was successful by entering command :
Get-ExecutionPolicy
Powershell should reply RemoteSigned

Ensure that the scripts below are copied and saved as Start.ps1 and Stop.ps1 in a directory. Ensure a copy of
SwitcherLib.dll
is also in the same directory
Adjust IP Addresses and File names accordingly

Once you are happy with the scripts you can rrun them by navigating to the directory and typing
.\start.ps1
or
.\stop.ps1

THE START SCRIPT : START.PS1

########################################################################


# record on multiple HyperDecks
$HyperDecks = @(
'10.10.161.31',
'10.10.161.32',
'10.10.161.33',
'10.10.161.34',
'10.10.161.35',
'10.10.161.36',
'10.10.161.37',
'10.10.161.38',
'10.10.161.39',
'10.10.161.40',
'10.10.161.41',
'10.10.161.42',
'10.10.161.43',
'10.10.161.44',
'10.1
0.161.45'
)

$DateString = (Get-Date).tostring("ddMMyyyy_hhmmss")

$fileNames = @(
"TX_$DateString",
"TX_BUP_$DateString",
"CAM1_$DateString",
"CAM2_$DateString",
"CAM3_$DateString",
"CAM4_$DateString",
"CAM5_$DateString",
"CAM6_$DateString",
"CAM7_$DateString",
"CAM8_$DateString",
"CAM9_$DateString",
"CAM10_$DateString",
"CAM11_$DateString",
"CAM12_$DateString",
"GFX1_$DateString"
)

<#
$i=0
foreach($HyperDeck in $HyperDecks)
{
echo $fileNames[$i]
$i++

}
#>

$sb = {
param ([string] $HyperDeckIP, [string] $HDcommand)
try {
          $socket = new-object System.Net.Sockets.TcpClient($HyperDeckIP, 9993)
          $stream = $socket.GetStream()
      $writer = new-object System.IO.StreamWriter($stream)

          $buffer = new-object System.Byte[] 512
          $encoding = new-object System.Text.AsciiEncoding
      
      $writer.WriteLine('remote: override: true')
      
      $writer.Flush()     
     
      Start-Sleep -m 50
      
      $writer.WriteLine($HDcommand)
      
      $writer.Flush()
      $writer.Close()

      while($stream.DataAvailable)
           {
                        $read = $stream.Read($buffer, 0, 1024)
                        $HyperDeckInfo = ($encoding.GetString($buffer, 0, $read))
           }
      $stream.Close()
             
  return $HyperDeckInfo
  }


catch {
     throw 'Failed to process HyperDeck {0}. The error was "{1}".' -f $HyperDeck, $_
    }


}

# Loop through each HyperDeck
$i=0
$jobs = @()
foreach($HyperDeck in $HyperDecks)
{
$jobs += Start-Job -ScriptBlock $sb -ArgumentList $HyperDeck, "record: name:$($fileNames[$i])"
$i++
Start-Sleep -m 50  

}

Start-Sleep -m 1000
echo 'All Hperdecks should be in record... Please check'

#########################################################################




THE STOP SCRIPT : STOP.PS1

#########################################################################

# STOP All hyperdecks
$HyperDecks = @(
'10.10.161.31',
'10.10.161.32',
'10.10.161.33',
'10.10.161.34',
'10.10.161.35',
'10.10.161.36',
'10.10.161.37',
'10.10.161.38',
'10.10.161.39',
'10.10.161.40',
'10.10.161.41',
'10.10.161.42',
'10.10.161.43',
'10.10.161.44',
'10.
10.161.45'
)

$sb = {
param ([string] $HyperDeckIP, [string] $HDcommand)
try {
            $socket = new-object System.Net.Sockets.TcpClient($HyperDeckIP, 9993)
            $stream = $socket.GetStream()
        $writer = new-object System.IO.StreamWriter($stream)

            $buffer = new-object System.Byte[] 1024
            $encoding = new-object System.Text.AsciiEncoding
        
        $writer.WriteLine('remote: override: true')
        
        $writer.Flush()     
       
        Start-Sleep -m 50
        
        $writer.WriteLine($HDcommand)
        
        $writer.Flush()
        $writer.Close()

        while($stream.DataAvailable)
             {
                          $read = $stream.Read($buffer, 0, 1024)
                          $HyperDeckInfo = ($encoding.GetString($buffer, 0, $read))
             }
        $stream.Close()
               
    return $HyperDeckInfo
    }
catch {
       throw 'Failed to process HyperDeck {0}. The error was "{1}".' -f $HyperDeck, $_
      }
}

# Loop through each HyperDeck
$i=0
$jobs = @()
foreach($HyperDeck in $HyperDecks)
{
 $jobs += Start-Job -ScriptBlock $sb -ArgumentList $HyperDeck, "stop"
 $i++
 Start-Sleep -m 50

}
    
Start-Sleep -m 1000     
echo 'All Hperdecks should be STOPPED'

#########################################################################


Comments / additions / errors to web20 at i w e u a dot c o m because I know almost NOTHING about Powershell!