Controll Blackmagic Hyperdeck from PowerShell

Having just acquired a HyperDeck, I wanted a bit more flexibility in controlling it than the from panel buttons provided. The ability to control the Hyperdeck via an Ethernet connection is very simple and well documented in the product manual so I set about building a simple PowerShell script to do the job. Source is here The script can take command line arguments to execute a number of sequential command to the HyperDeck or run in interactive mode, taking keyboard input to perform actions. Below is a screen shot showing details about the device and clips. HyperDeck POSH

<pre>## HyperDeckTest.ps1
## By Ian Morrish
## Control Blackmagic HyperDesk via Ethernet from Windows PowerShell. PowerShell is part of all modern Windows desktop/server products
## see
## To run the script requires enabling PowerShell Script file execution. Run the following command to allow only local scripts to be executed
##    set-executionpolicy remotesigned
#run with command line e.g.
#   PS > .\HyperDeckTest.ps1 -remoteHost "" -commands @('remote: override: true', 'goto: clip id: 2','play: single clip: true')
#Or with no commands to get interactive menu mode 
#default parameters below are used if you don't provide any (update HyperDeck IP address if you want to run in interactive mode)
param( [string] $HyperDeckIP = "", [string[]] $commands = @('remote: override: true'))
$port = 9993
$TempLogFilePath = "c:\temp\HyperDeck.log"
function WriteCommand($strCommand){

		## Write single command to the HyperDeck
        write-host $strCommand
        Start-Sleep -m 500
        while($stream.DataAvailable) {
			$read = $stream.Read($buffer, 0, 1024)
			write-host -n ($encoding.GetString($buffer, 0, $read))

Start-Transcript -Path "$TempLogFilePath"

	write-host "Connecting to $HyperDeckIP on port $port"
	$socket = new-object System.Net.Sockets.TcpClient($HyperDeckIP, $port)

	if($socket -eq $null) {
		write-host "Failed to connect to $HyperDeckIP on port $port"

	$stream = $socket.GetStream() 
    $writer = new-object System.IO.StreamWriter($stream)

	$buffer = new-object System.Byte[] 1024
	$encoding = new-object System.Text.AsciiEncoding

	#Loop through $commands and execute one at a time.

	for($i=0; $i -lt $commands.Count; $i++) { ## Allow data to buffer for a bit start-sleep -m 500

		## Read all the data available from the stream, writing it to the ## screen when done.
		while($stream.DataAvailable) {
			$read = $stream.Read($buffer, 0, 1024)
			write-host -n ($encoding.GetString($buffer, 0, $read))

		write-host $commands[$i]
		## Write the command to the remote host
        Start-Sleep -m 500

if ($commands.Count -eq 1){
    ## run in interactive mode
do {$strResponse = Read-Host "Shorcuts = ? - help, di - device Info, ci - clip info, p - play, s - stop, 1-10 clip, Q when you want to quit application?"

    switch ($strResponse)
            "?" {WriteCommand('help')}
            "c" {WriteCommand('configuration')}
            "ci" {WriteCommand('clips get')}
            "di" {WriteCommand('device info')}
            "s" {WriteCommand('stop')}
            "p" {WriteCommand('play')}
            "r" {WriteCommand('record')}
            "1" {WriteCommand('goto: clip id:1')}
            "2" {WriteCommand('goto: clip id:2')}
            "3" {WriteCommand('goto: clip id:3')}
            "4" {WriteCommand('goto: clip id:4')}
            "5" {WriteCommand('goto: clip id:5')}
            "6" {WriteCommand('goto: clip id:6')}
            "7" {WriteCommand('goto: clip id:7')}
            "8" {WriteCommand('goto: clip id:8')}
            "9" {WriteCommand('goto: clip id:9')}
            "10" {WriteCommand('goto: clip id:10')}
	    default {WriteCommand($_)}

until ($strResponse -eq "Q") 
	## Close the streams
	## Cleans everything up.

    write-host "exit"
     #   start-sleep -m 500
    while($stream.DataAvailable) {
			$read = $stream.Read($buffer, 0, 1024)
			write-host -n ($encoding.GetString($buffer, 0, $read))
	#The end</pre>

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s