<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Trond&#039;s Working!Trond&#039;s Working! - Tag Archive for &quot;Plex&quot;  </title>
	<atom:link href="http://hindenes.com/trondsworking/tag/plex/feed/" rel="self" type="application/rss+xml" />
	<link>http://hindenes.com/trondsworking</link>
	<description>Ramblings about Windows, Powershell, System Center and IT Management</description>
	<lastBuildDate>Tue, 18 Jun 2013 11:32:50 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>PowerShell module for Plex Media Server (PMS) v.0.1</title>
		<link>http://hindenes.com/trondsworking/2012/02/02/powershell-module-for-plex-media-server-pms/</link>
		<comments>http://hindenes.com/trondsworking/2012/02/02/powershell-module-for-plex-media-server-pms/#comments</comments>
		<pubDate>Thu, 02 Feb 2012 09:07:08 +0000</pubDate>
		<dc:creator>Trond</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Fun]]></category>
		<category><![CDATA[Plex]]></category>
		<category><![CDATA[Powershell]]></category>

		<guid isPermaLink="false">http://hindenes.com/trondsworking/?p=125</guid>
		<description><![CDATA[Since I started using Plex, I thought it would be nice to be able to issue simple control commands to it, like pause music when I need to make a phone call. Also, when writing PowerShell code it’s sometimes nice to have 20 seconds of quiet, just to be able to construct a complex bit</p><a href="http://hindenes.com/trondsworking/2012/02/02/powershell-module-for-plex-media-server-pms/">(More)…</a>]]></description>
				<content:encoded><![CDATA[<p>Since I started using Plex, I thought it would be nice to be able to issue simple control commands to it, like pause music when I need to make a phone call. Also, when writing PowerShell code it’s sometimes nice to have 20 seconds of quiet, just to be able to construct a complex bit of regex or whatever. </p>
<p>So, although this is very much work in progress, here’s the 0.1 version of my PowerShell module for Plex – PSPlex.</p>
<p>If you just want to get it up and running, just read the next bit. If you’re interested in how it works, read the rest too.</p>
<p>Basics:</p>
<p>The module consists of 2 files, a PowerShell script and a xml file for controlling it. The xml file holds info about your Plex server and the commands you can send to it. The two files need to sit in the same directory (in this version at least).</p>
<p><strong>To set up:     <br /></strong>1. Go ahead and download the zip file, unzip to C:\PSPlex for instance    <br />2. Open notepad and edit the xml file (replace the servername with your own plex server, mine is named “trond-8730w”)    <br />3. Fire up PowerShell, navigate to the folder where you unzipped the files, and type in “Import-module .\PSPlex.ps1”    <br />4. The PowerShell scripts contacts your server, prompts you to chose a player (if you have more than one) and generates commands from the xml file (as of now there’s only play, pause, next and stop)    <br />5. From within PowerShell, simply type pause to stop your currently playing music, and play to start playing again.</p>
<p>(If you get any errors related to script execution, google “PowerShell Execution Policy”)</p>
<p>&#160;</p>
<p><strong>How the script works:</strong></p>
<p>The PlexNine remote API is rest-based, which makes it a breeze to control – it’s just a matter of issuing commands in the form of http get commands – this is documented here:    <br /><a title="http://forums.plexapp.com/index.php/topic/15850-plex-9-remote-api/" href="http://forums.plexapp.com/index.php/topic/15850-plex-9-remote-api/">http://forums.plexapp.com/index.php/topic/15850-plex-9-remote-api/</a></p>
<p>You can actually control your Plex system from your browser by using the corresponding URL for what you want.</p>
<p>I also needed a way to list a server’s players, which is also available in the same API.</p>
<p>I quickly found it boring to write a command for each of the command I needed (play, pause, so on), so I came up with this idea of “dynamic commands”. PowerShell doesn’t have any built-in support for this (at least not that I’ve found), so I decided to simply write a bunch of PowerShell files from inside the script to the user’s temp folder, and then dot-source these in order to dynamically construct the necessary commands. This means that you can simply extend the script with the commands you want.   </p>
<p><a href="http://hindenes.com/trondsworking/wp-content/uploads/2012/02/image.png" rel="lightbox[125]" title="image"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://hindenes.com/trondsworking/wp-content/uploads/2012/02/image_thumb.png" width="644" height="108" /></a></p>
<p>This is an example of an entry in the xml. The CommandName is the name of the PowerShell command generated, and the CommandRestCommand is the corresponding Plex API command. For now, I’ve only implemented support for “playback controller” commands, as described in the link above.</p>
<p>In short, download the script, edit the xml file and play with it. This is only a very small part of what I’d like to do, so keep watching this space!</p>
<p>Download the script and xml file here:</p>
<p><a href="http://www.hindenes.com/powershell/PSPlex.zip" target="_blank">http://www.hindenes.com/powershell/PSPlex.zip</a></p>
<p>Keep watching this space for updates!</p>
]]></content:encoded>
			<wfw:commentRss>http://hindenes.com/trondsworking/2012/02/02/powershell-module-for-plex-media-server-pms/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
