# Create a folder for the moduleNew-Item-Path"$home\Documents\WindowsPowerShell\Modules\PayByPhone"-ItemTypeDirectory-ErrorActionSilentlyContinue-Force|Out-Null# Create a very minimal Pipeworks manifest@'
@{
SecureSetting = 'MyStripeKey'
WebCommand = @{
"Receive-PhonePayment" = @{
Hidden = $true
}
}
}
'@|Set-Content"$home\Documents\WindowsPowerShell\Modules\PayByPhone\PayByPhone.Pipeworks.psd1"@'
@{
ModuleVersion = 0.1
ModuleToProcess = 'PayByPhone.psm1'
}
'@|Set-Content"$home\Documents\WindowsPowerShell\Modules\PayByPhone\PayByPhone.psd1"@'
. $psScriptRoot\Receive-PhonePayment.ps1
'@|Set-Content"$home\Documents\WindowsPowerShell\Modules\PayByPhone\PayByPhone.psm1"{functionReceive-PhonePayment{<#
.Synopsis
Receives payments over the phone
.Description
Thank you for making a payment.
#>param(# How much would you like to pay?[Parameter(Mandatory=$true,Position=0)][Double]$Amount,# What is the card number?[Parameter(Mandatory=$true,Position=0)][Uint32]$CardNumber,# What is the number of the expiration month?[Parameter(Mandatory=$true,Position=1)][Uint32]$ExpirationMonth,# What is the number of the expiration year?[Parameter(Mandatory=$true,Position=2)][Uint32]$ExpirationYear,# What is the card verification code?[Parameter(Mandatory=$true,Position=2)][Uint32]$CardVerficationCode)process{$paymentInfo=Get-Paid@PSBoundParameters-StripeKeySettingMyStripeKey-Currencyusd-ErrorActionSilentlyContinue-ErrorVariableProblemsHaveHappenedif(-not$paymentInfo){"I'm sorry, your payment cannot be processed."}else{"Thank you for your payment."}}}}|Set-Content"$home\Documents\WindowsPowerShell\Modules\PayByPhone\Receive-PhonePayment.ps1"Import-ModulePayByPhone-Force-PassThru|ConvertTo-ModuleService-Force-Do"/Receive-PhonePayment/?CallSid=123&AccountSid=abc&From=12065551212&To=12065551212"-AsIntranetSite-Port2121

ShowUI is another tool Start-Automating makes to help power UI over PowerShell. You can download Pipeworks, ShowUI, and more when you download IsePackV2.

With ShowUI and Pipeworks, you can create a WPF credit card terminal in 55 lines of code.

In our next example, we'll make a quick module into a software service.

# In Pipeworks, you need 3 files to make a module.# The Script Module ( ModuleName.PSM1),# The Module Manifest ( ModuleName.PSD1)# The Pipeworks Manifest (ModuleName.Pipeworks.psd1)# This will check for the module directory and create it if it doesn't exist.$modulePath="$home\Documents\WindowsPowerShell\Modules\SayHello"if(-not(Test-Path$modulePath)){New-Item-ItemTypeDirectory-Path$ModulePath|Out-Null}# Our module will be simple. It will have one command, Show-HelloMessage.# We'll include it inside of the .PSM1@'
function Show-HelloMessage
{
<#
.Synopsis
Shows a hello message
.Description
Shows a personalized hello message
#>
param(
# What is your name?
[Parameter(Mandatory=$true)]
[string]
$YourName
)
"Hello $YourName"
}
'@|Set-Content"$modulePath\SayHello.psm1"# The Module Manifest File is pretty simple.# It includes a version, a description, and it refers to the .PSM1@'
@{
ModuleVersion = '1.0'
ModuleToProcess = 'SayHello.psm1'
Description = 'Say Hello, Wave Goodbye'
}
'@|Set-Content"$modulePath\SayHello.psd1"# The Pipeworks Manifest describes how the module will turn into a web service, and what it can do.# You can create a Pipeworks Manifest by hand, or you can use the New-PipeworksManifest commandNew-PipeworksManifest-NameSayHello-WebCommand@{"Show-HelloMessage"=@{FriendlyName='Say Hello'}}|Set-Content"$modulePath\SayHello.Pipeworks.psd1"# To create your web service, run the following command:Import-ModuleSayHello-Force-PassThru|ConvertTo-ModuleService-Force# You can now navigate to http://localhost/SayHello and make it greet you

The second sample shows some of the Powers of Pipeworks:

You can create a software service in seconds out of any PowerShell command

You can convert PowerShell to a web experience without really thinking about it

We'll get a little more complex by creating a service that lets you log in.

# This module is also very simple, and requires the same few files.# It's called "ShowMe", and it simply shows the currently logged on user.$modulePath="$home\Documents\WindowsPowerShell\Modules\ShowMe"if(-not(Test-Path$modulePath)){New-Item-ItemTypeDirectory-Path$ModulePath|Out-Null}# The Module Manifest File is pretty simple.# It includes a version and it refers to the .PSM1@'
@{
ModuleVersion = '1.0'
ModuleToProcess = 'ShowMe.psm1'
}
'@|Set-Content"$modulePath\ShowMe.psd1"# Our .PSM1 contains the Show-Me function@'
function Show-Me
{
<#
.Synopsis
Shows me
.Description
Shows information about the currently logged in user
.Example
Show-Me
#>
if (-not ($request -and $response -and $session)) {
Get-Person -Alias $env:USERNAME
} else {
if ($session["User"]) {
# If there's a user, just output them
return $session["User"]
} else {
throw "Not logged in"
}
}
}
'@|Set-Content"$modulePath\ShowMe.psm1"# Our pipeworks manifest is pretty simple.# We provide the name of the module, and a hashtable containing what commands we want to turn into services:# Each value in this table should be another hashtable containing parameters for the command [Invoke-WebCommand](http://powershellpipeworks.com/)New-PipeworksManifest-NameShowMe-WebCommand@{"Show-Me"=@{RequireLogin=$trueRunWithoutInput=$trueFriendlyName='Show Me'}}|Set-Content"$ModulePath\ShowMe.Pipeworks.psd1"# To let us log into the module service, we'll publish it as an Intranet site:Import-ModuleShowMe-Force-PassThru|ConvertTo-ModuleService-AsIntranetSite-Port222-ForceStart-Processhttp://localhost:222/

]]>Pipeworks Quickstart/
What Pipeworks DoesStart-AutomatingTue, 02 Sep 2014 00:56:43 GMT PowerShell Pipeworks does a lot more than most web languages.
The goal of Pipeworks is to be able to create web sites and services quickly, cheerfully, and nicely. The aim is to remove as many painful little parts of the process as possible.

Pipeworks provides the toolkit you'll need to write the frontend and backend of almost any application you can imagine. In other words, it helps you put it all together with PowerShell.

These tools fall into a few general categories:

Frontend Functions

One of the major differences between Pipeworks and, say, PHP, is the amount of functionality designed to help you generate HTML. Pipeworks contains many helper functions that write complex HTML for you, and it provides a Less.css template to help spruce up your site.

Sweet Software Services

Nowadays, no web site is an island. Many sites and services leverage well known and trusted web services to help lighten the load. Pipeworks includes a number of functions to interact with these software services.

Deployment Tools

Every site needs a little bit of setup. These commands can help you manage your deployments and configure your machines:

Add-Deployment/ Get-Deployment / Import-Deployment / Publish-Deployment / Push-Deployment / Remove-Deployment / Switch-TestDeployment / Wait-Deployment - This family of commands help you manage which modules get deployed, and where they get deployed to.

ConvertTo-ModuleService - This is the "heavy lifter" in Pipeworks. It performs the actual conversion of your module into a web site and service.

Start-At - Lets you schedule tasks on the machine, including tasks with advanced triggering, such as new email received or data changes within a table or database

Open-Port / Close-Port - These functions open and close ports on a box

Install-PSNode / Start-PSNode - Helps you install and run PSNode, a very lightweight interactive web server included in Pipeworks

Add-AzureLocalResource, Add-AzureRole, Add-AzureSetting, Add-AzureStartupTask, Add-AzureWebSite, New-AzureServiceDefinition, Out-AzureService - These commands help you build service deployments in Azure. Commonly, these commands will be called for you when you publish a deployment.

Add-SecureSetting / Get-SecureSetting / Remove-SecureSetting - These commands help you manage secure information (for instance, user name and passwords) for use in your scripts and services

]]>What Pipeworks Does/
Building with Blob StorageStart-AutomatingTue, 27 May 2014 06:38:55 GMT
Sometimes structured storage isn't really what you're after. Sometimes, you just want to throw a blob of bytes into the cloud and call it a day.

For these times, Pipeworks provides commands to interact with Azure Blob Storage. To run this demo yourself, you need to use Add-SecureSetting to set up your access keys first.

]]>Building with Blob Storage/
Simplified SQLStart-AutomatingTue, 27 May 2014 00:51:27 GMT
PowerShell Pipeworks contains several functions to help you simplify interaction with SQL.

The core functions are:

Add-SQLTable

Get-SQLTable

New-SQLDatabase

Remove-SQL

Select-SQL

Update-SQL

The two important ones for you to remember are:

Select-SQL, which runs SQL and unrolls each result

Update-SQL, which takes a pipeline of objects and updates a SQL database

To show you how these work, let's create and update a simple table.

First, we need to create a new database. This example requires that you run it on a computer with SQL server

# Create a random DB name$dbName="Db"+(Get-Random)# Create the database on the local computerNew-SQLDatabase-DatabaseName$dbName# Craft a connection string to the database$connectionString="Data Source=$env:ComputerName;Initial Catalog=$dbName;Integrated Security=SSPI;"

Now we need to create some input for our table. We'll do this by creating a pair of random input objects, and then piping them into Update-SQL. If you provide -Force to Update-SQL, it will create the table and modify it to fit your input object.

# Create the list of input objects$inputObjs=@()# Add a couple of items to the list$inputObjs+=New-ObjectPSObject-Property@{"a"=Get-Random"B"=Get-Random}$inputObjs+=New-ObjectPSObject-Property@{"a"=Get-Random"B"=Get-Random}$inputObjs|Update-Sql-TableName"TestTable"-Force-connectionStringOrSetting$connectionString

Now let's query the table to check that the items were inserted. Since we've already supplied a connection string, we don't need to do it again

Select-SQL-FromTableTestTable

Great! Now let's query again, and this time let's modify the values for B

It's great that Pipeworks simplifies SQL, but it also gives you easy access to full SQL. Select-SQL has an alias, "sql", and it's first positional parameter is a raw SQL statement. This means you can write as complicated SQL as you'd like in PowerShell with very simple syntax like this:

]]>About the Pipeworks Manifest - AdSense/
The Pipeworks ManifestStart-AutomatingMon, 09 Dec 2013 08:18:57 GMT The Pipeworks Manifest is a PowerShell data file that is used to configure your module as a web service.
It contains data to drive your service, deployment information, and pointers to secure information. It's one PowerShell hashtable, and it's used as a very extensible configuration system. You can always reference the Pipeworks Manifest inside of a Pipeworks module with the variable $pipeworksManifest

The Pipeworks manifest is used pervasively in Pipeworks. You can create a Pipeworks manifest with the New-Pipeworks manifest command, and you should learn to edit the Pipeworks manifest by hand and understand it's sections.

]]>About the Pipeworks Manifest - Facebook/
About the Pipeworks Manifest - ExecutionTimeoutStart-AutomatingMon, 09 Dec 2013 06:24:43 GMTAbout the Pipeworks Manifest - ExecutionTimeout/
About the Pipeworks Manifest - DownloadStart-AutomatingMon, 09 Dec 2013 06:23:13 GMTAbout the Pipeworks Manifest - Download/
About the Pipeworks Manifest - DomainSchematicsStart-AutomatingMon, 09 Dec 2013 06:21:39 GMT
A site can be published to multiple domains. To do this, separate each item with a |
Here's an example of a site that would be published to 4 different URLs, using the default schematic:

]]>About the Pipeworks Manifest - DomainSchematics/
About the Pipeworks Manifest - DefaultTemplateStart-AutomatingMon, 09 Dec 2013 06:18:19 GMTAbout the Pipeworks Manifest - DefaultTemplate/
About the Pipeworks Manifest - DefaultCommandStart-AutomatingMon, 09 Dec 2013 06:17:25 GMT
It is a hashtable, and must contain the name of the command. It may contain a nested hashtable called Parameter, which will provide parameters to the command.

DefaultCommands do not need to be registered as web commands, since they cannot accept open-ended input.

Here is an example:

@{DefaultCommand=@{Name='Get-RandomPowerShellTip'}}

]]>About the Pipeworks Manifest - DefaultCommand/
About the Pipeworks Manifest - CssStart-AutomatingMon, 09 Dec 2013 06:13:56 GMT
It is a hashtable, with the key describing the style page and the value containing the path to the page.

Here's a quick example of the CSS section:

@{Css=@{"PowerShellStyleSheet"="/CSS/Gangamstyle.css"}}

]]>About the Pipeworks Manifest - Css/
About the Pipeworks Manifest - CommandTriggerStart-AutomatingMon, 09 Dec 2013 06:12:23 GMT
Here is an example of a Pipeworks manifest with a CommandTrigger section:

@{CommandTrigger=@{"Shake"="Get-RandomPowerShellTip"}}

]]>About the Pipeworks Manifest - CommandTrigger/
About the Pipeworks Manifest - CommandTemplateStart-AutomatingMon, 09 Dec 2013 06:10:18 GMTAbout the Pipeworks Manifest - CommandTemplate/
About the Pipeworks Manifest - CommandOrderStart-AutomatingMon, 09 Dec 2013 06:08:27 GMTAbout the Pipeworks Manifest - CommandOrder/
About the Pipeworks Manifest - BrandingStart-AutomatingMon, 09 Dec 2013 06:04:57 GMTAbout the Pipeworks Manifest - Branding/
About the Pipeworks Manifest - BootstrapStart-AutomatingMon, 09 Dec 2013 06:03:55 GMT
If the theme is not present, this will download a twitter bootstrap theme according using color scheme specified in the Style section of the Pipeworks manifest. To refresh the them, delete bootstrap.js from the JS directory of the module and republish.

Using Bootstrap enables many features within Pipeworks, and changes the default layout. It enables a navbar that links to the topics and commands in the module. It also changes the deault view to a set of HangingSpans, which will expand out when clicked.
]]>About the Pipeworks Manifest - Bootstrap/
About the Pipeworks Manifest - BlogStart-AutomatingMon, 09 Dec 2013 06:00:34 GMTAbout the Pipeworks Manifest - Blog/
About the Pipeworks Manifest - BingValidationKeyStart-AutomatingMon, 09 Dec 2013 05:53:45 GMTBing Webmaster Tools
]]>About the Pipeworks Manifest - BingValidationKey/
About the Pipeworks Manifest - AsIntranetSiteStart-AutomatingMon, 09 Dec 2013 05:50:21 GMTAbout the Pipeworks Manifest - AsIntranetSite/
About the Pipeworks Manifest - AppPoolUserStart-AutomatingMon, 09 Dec 2013 05:49:18 GMT
If this and AppPoolPasswordSetting are provided, the module will be published under a specific app pool user account. This can be very useful for Intranet modules that need to run as a particular user.
See Also:

]]>About the Pipeworks Manifest - AppPoolUser/
About the Pipeworks Manifest - AppPoolPasswordSettingStart-AutomatingMon, 09 Dec 2013 05:49:14 GMT
If this and AppPoolUser are provided, the module will be published under a specific app pool user account. This can be very useful for Intranet modules that need to run as a particular user.
See Also:

ConvertFrom-Markdown@'
Markdown is used pervasively in [PowerShell Pipeworks](http://powershellpipeworks.com).
* About topics (.help.txt) are automatically converted into Markdown
* Walkthru files (.walkthru.help.text) can use markdown to in the demo text.
* Functions may use markdown to spruce up the help in their parameters.
'@

Markdown can also make numbered lists, like this step-by-step list of instructions for getting started with Pipeworks.

]]>New-Webpage and JQuery/
Pipeworks Writes CRUDStart-AutomatingWed, 04 Dec 2013 07:56:48 GMT
CRUD is a standard set of operations that most web applications need to perform.

It stands for:
Create, Read, Update, and Delete
Rather than make you write all of the CRUD yourself, you can create a simple set of CRUD commands with the Pipeworks function Write-Crud.

The simplest way to create a CRUD system with Write-Crud is to use schemas. For instance, this creates the CRUD system for a blog:

Write-Crud-TableMy-PartitionBlog-Schemahttp://schema.org/BlogPosting

Another site that lists schemas is shouldbeonschema.org

Write-Crud-TableMy-PartitionFAQ-Schemahttp://shouldbeonschema.org/FAQ

If you don't find the schema you like on schema.org, you can define a custom CRUD system

Write-CRUD-TableMy-PartitionCustomItem-TypeNameMyCustomCrud-Field@{'Name'='The Name of the Item''Description'='The description of the item'}

]]>Pipeworks Writes CRUD/
Pick up the Phone with PipeworksStart-AutomatingWed, 04 Dec 2013 07:56:48 GMT
One of the most powerful examples of what you can do in PowerShell Pipeworks is having it pick up the phone. It's a lot easier than you'd think.

The core of how PowerShell Pipeworks works is that it leverages the rich metadata in each PowerShell function to generate different experiences around that function. This means that all functions work when they are called over the phone from a Twilio number.

This example is simple and very powerful. It's a function that takes a phone call, a text message, or an web page, and sends it to an email.

Create a folder for the module

New-Item-Path"$home\Documents\WindowsPowerShell\Modules\GetBack"-ItemTypeDirectory-ErrorActionSilentlyContinue-Force|Out-Null# Create a very minimal Pipeworks manifest@'
@{
SecureSetting = 'SmtpEmail', 'SmtpPassword'
WebCommand = @{
'Request-Information' = @{
FriendlyName = 'Get In Touch'
Hidden = $true
}
}
}
'@|Set-Content"$home\Documents\WindowsPowerShell\Modules\GetBack\GetBack.pipeworks.psd1"# An a minimal module manifest@'
@{
ModuleVersion = 0.1
ModuleToProcess = 'GetBack.psm1'
}
'@|Set-Content"$home\Documents\WindowsPowerShell\Modules\GetBack\GetBack.psd1"@'
. $psScriptRoot\Request-Information.ps1
'@|Set-Content"$home\Documents\WindowsPowerShell\Modules\GetBack\GetBack.psm1"{functionRequest-Information{<#
.Synopsis
Receives phone calls, text messages, or contact info
.Description
Thank you for getting in touch.
#>param(# What can we help you with?#|LinesForInput 6#|Record[Parameter(Mandatory=$true,Position=0,ValueFromRemainingArguments=$true)][string]$Message,# Who are we helping?[Parameter(Mandatory=$true)][ValidateScript({if(-not$request["AccountSid"]){if($_-notlike"*@*.*"){throw"invalid address"}else{return$true}}else{return$true}})][string]$From)process{$smtpEmail=Get-SecureSetting-NameSmtpEmail-ValueOnly$smtpPassword=Get-SecureSetting-NameSmtpPassword-ValueOnly$smtpCred=New-ObjectManagement.Automation.PSCredential".\$smtpEmail",(ConvertTo-SecureString-AsPlainText-Force$smtpPassword)if($Message-like"http*"){Send-MailMessage-Toinfo@company.com-Frominfo@company.com-Body(Write-Link-Url$Message-Caption"Listen To Message")-BodyAsHtml-Subject"Message From $From"-UseSsl-Credential$smtpCred-SmtpServersmtp.outlook.com}else{Send-MailMessage-Toinfo@company.com-Frominfo@company.com-Body$Message-Subject"Message From $From"-UseSsl-Credential$smtpCred-SmtpServersmtp.outlook.com}"Thank you for contacting us. We will get back to you shortly."}}}|Set-Content"$home\Documents\WindowsPowerShell\Modules\GetBack\Request-Information.ps1"Import-ModuleGetBack-Force-PassThru|ConvertTo-ModuleService-Force-Do"/Request-Information"-AsIntranetSite-Port1919

Once that function is published to a URL, you can configure your Twilio numbers so that calls are routed to that function's URL.

Function parameters that share names with the Twilio request parameters will be automatically provided (the same is true when the handler is receiving a text message).

Positional parameters are handled in order, and the return values are converted into TwilML.

For instance, if you return a string from a function, Twilio will read it with the Say verb. If that string starts with http, Twilio will Play it with the Play verb. If the result could be XML, it will return the result inside of the TwilML.

]]>Pick up the Phone with Pipeworks/
Looking Up Locations With Resolve-LocationStart-AutomatingWed, 04 Dec 2013 07:56:48 GMT
Every once in a while, you want to be able to locate a real spot somewhere on the face of the planet.

Pipeworks includes a cool cmdlert for just this purpose: Resolve-Location.

The first works off of IP addresses, and the second works only for US addresses.

Both resolve a location to a http://schema.org/Place. When you view a Place inside of a web page, it will automatically embed a map.

This first example will map an IP.

Resolve-Location67.161.126.141

And this will show you where the White House is.

Resolve-Location"1600 Pennsylvania Ave, Washington, DC"

]]>Looking Up Locations With Resolve-Location/
From Script To Software ServiceStart-AutomatingWed, 04 Dec 2013 07:56:48 GMT
The most important section of the Pipeworks manifest to understand is WebCommand. Without putting anything in WebCommand, your PowerShell scripts will not be able to be run as software services.

WebCommand is a hashtable containing the names of the commands you will turn into web services, and arguments to the command Invoke-WebCommand. Invoke-WebCommand is the command that runs an individual PowerShell cmdlet as a web service, in all of it's varieties.

For instance, the Pipeworks Quickstart contains a simple example function, Show-HelloMessage, and this simple command to create a Pipeworks manifest and run it.

We also need to have a Pipeworks manifest. In this manifest, we'll register one web command: Find-BikeStation, with a friendly name.

{@{UseBootstrap=$trueDomainSchematics=@{"CitiBike.PowerShellPipeworks.com"="Default"}WebCommand=@{"Find-BikeStation"=@{FriendlyName="Find a Bike"}}}}|Set-Content"$home\Documents\WindowsPowerShell\Modules\CitiBike\CitiBike.Pipeworks.psd1"

The Find-BikeStation function is fairly simple.

It contacts CitiBank to pull down a list of Bike Stations and caches it in memory.

Then it compares the query you entered to the list, and returns all matching items in one object.

It's very important to note that the output object is given it's own type name, which lets us format the object however we'd like. The code that does this looks like so:

]]>Creating a CitiBike Station Finder/
Building With BootstrapStart-AutomatingWed, 04 Dec 2013 07:56:48 GMT
Pipeworks 1.8 includes support for Twitter Bootstrap. You can make any Pipeworks manifest support bootstrap by setting UseBootstrap to true

New-PipeworksManifest-UseBootstrap-NameBootstrapper

When you use bootstrap, it will check for a bootstrap.js file, and, if one isn't found, it downloads the latest Bootstrap.

It will use the background-color and color set in the Pipeworks Manifest Style section.

For convenience, you can use New-PipeworksManifest -ForegroundColor and -BackgroundColor to set these more simply

]]>Working With Write-Link/
Publishing Pipeworks To AzureStart-AutomatingWed, 04 Dec 2013 07:56:48 GMT
Azure can be really amazing. Azure compute instances are Microsoft's own version of Windows Server, and they've got a very valuable deployment system.

Azure Web Roles can be configured to host many sites with many different host headers onto a single deployment. While these types of deployments are usually hard to create, Pipeworks can pop them right out.

This means that anyone can make a massively multitenant Azure deployment with Pipeworks. The Pipeworks deployment presently has around 60 different apps, running over 150 different domains, and running at 11% memory / 2% CPU on a single Azure instance.

It's easy to drop in many deployments by simply using the DomainSchematics section of the Pipeworks manifest. This shows the domain schematics section for Pipeworks.

The Azure team is nice enough to make a nifty PowerShell module of their own. With it, it's simple to upload a package to the staging environment.

This easily adaptable snippet will take your package and automatically upload it to Azure.

# Import AzureImport-ModuleAzure# Obviously, change these to fit your own deployment.$myServiceName='myService'$MyServiceLabels='Sites1','Sites2'$MyDeploymentName='MyDeployment'# Get your current deployment$currentDeployment=Get-AzureDeployment-ServiceName$myServiceName# Pick a label for the new deployment$newlabel=if($currentDeployment.label-ne$myServiceLabels[0]){$myServiceLabels[1]}else{$myServiceLabels[0]}# Remove the old deploymentRemove-AzureDeployment-ServiceName$myServiceName-SlotStaging-Force-ErrorActionSilentlyContinue$deploymentParameters=@{Package="$home\Documents\$MyDeploymentName\$MyDeploymentName.cspkg"Configuration="$home\Documents\$MyDeploymentName\$MyDeploymentName.cscfg"Label=$newLabel}# Put the deployment in the staging slotNew-AzureDeployment@deploymentParameters-ServiceName$mySeriveName-SlotStaging

]]>Publishing Pipeworks To Azure/
Integrated IntranetStart-AutomatingWed, 04 Dec 2013 07:56:48 GMT
Since most web languages come from a linux background, making them work with windows is often like trying to fit a round peg into a square hole.

Most enterprise IT applications need to do things like work with Active Directory, Exchange, or Sharepoint - Technologies PowerShell already works well with.
You can use the -AsIntranetSite parameter on ConvertTo-ModuleService along with -AppPoolCredential to make any module available on your intranet as a certain user.

PowerShell Pipeworks also includes a useful function to look up information from Active Directory: Get-Person.
]]>Integrated Intranet/
Why WindowsStart-AutomatingWed, 04 Dec 2013 07:56:48 GMT We all know that Windows is the workhorse of the workplace. Understanding why helps make the case for why you should build your web application on Windows.
To paraphrase the Hitchhiker's Guide to the Galaxy: Windows is big. Really big.
Windows has been expanding for over 20 years and, believe it or not, that expansion has been largely dictated by what large customers of Windows wanted. This means that buried within Windows are literally millions of things you can do programatically.
In constrast, OsX has been expanding for about 10 years now, and that expansion is largely dictated by what small customers want. Throughout OsX one encounters cases where it's possible to click but not script your way through and interaction.
While Linux has been expanding for roughly 40 years, it's been largely expanding based off of the needs of the developers working on individual parts. This means that many parts overlap and do not usually play well together.
To get a simple idea of just how big Windows is, a box with nothing than Windows, Office, and Skype contains roughly:

3000 COM Objects

7000 WMI Classes

30000 .NET Classes

Put another way, Windows has 40,000 fairly well structured solutions right out of the box, not counting the tens of thousands of small C operations that you can do. Since Apple and Linux have no mechanism for discoverying programmatic capabilites on a machine, there isn't even a way of knowning how large the gap is.

Not only are there so many solutions built into the box of Windows, there's an astounding amount of documentation about most of the capabilities of the operating system. This means that there's a considerably higher chance of being able to actually write a complex application at all.
]]>Why Windows/
New-Region And JQueryUIStart-AutomatingWed, 04 Dec 2013 07:56:48 GMT
New-Region makes it simple to create sites that use JQueryUI to add a little extra kick.

New-Region takes a simple table in PowerShell containing a layer name and content.

By using several different switches, you can customize how this is laid out in JQueryUI.

New-Region-LayerIdSimpleTabs-Layer@{"-AsTab"="If you use -AsTab, the Region will be created as a tab""Makes Tabs Easy"="Did you know you can add hashtables together in PowerShell? This can make really cool layout really simple.""Tabs Will Be Alphabetized"="By Default, the Layers will be alphabetized""Unless You Say So"="But you can specify your own layer order with -Order"}-AsTab

-AsAccordian will create a JQueryUI accordian instead

New-Region-LayerIdSimpleAccordian-Layer@{"-AsAccordian"="If you use -AsAccordian, the Region will be created as an accordian""Makes Accordians Easy"="Did you know you can add hashtables together in PowerShell? This can make really cool layout really simple.""Tabs Will Be Alphabetized"="By Default, the Layers will be alphabetized""Unless You Say So"="But you can specify your own layer order with -Order"}-AsAccordian

-AsPopup will create Popups.

New-Region-LayerIdSimplePopup-Layer@{"-AsPopup"="If you use -AsPopup, the Region will be created as a popup.<br/>
Please, remember that most users really hate popups, but, in case you need it, here it is."}-AsPopup

-AsPopout might be a better alternative. It pops the content out directly below a wide button.

New-Region-LayerIdSimplePopout-Layer@{"-AsPopout"="If you use -AsPopout, then a wide button will toggle if the region is displayed."}-AsPopout

-AsPopdown will create a small button that pops out content directly below.

If multiple items are expanded, they will be stacked.

New-Region-LayerIdSimplePopdown-Layer@{"-AsPopdown"="If you use -AsPopdown, then a button will toggle if the region is displayed, and all displayed regions will be stacked""A Second Region"="Here's a second region, so you can see how multiple popdowns expand"}-AsPopdown

You can combine -AsResizable and -AsDraggable for resizable, draggable widget

New-Region-LayerIdSimpleResizableWithContent-Style@{width='300px';height='300px'}-Layer@{"Drag Me and Resize Me"="-AsDraggable and -AsResizable are not exclusive"}-asdraggable-asresizable

]]>New-Region And JQueryUI/
Scripting With SuperglueStart-AutomatingWed, 04 Dec 2013 07:56:48 GMT
Out of the box, PowerShell works wonderfully with:

Anything from .NET

Almost all COM Objects

Anything from WMI

Any .exe

Any SOAP Web service (with New-WebServiceProxy)

Any REST web service (with System.Net.Webclient)

Low-Level windows Operations (via P/Invoke)

And if this wasn't enough, you can use the built in PowerShell cmdlet Add-Type to compile your way there.
]]>Scripting With Superglue/
JQueryUI In PipeworksStart-AutomatingWed, 04 Dec 2013 07:56:48 GMT JQueryUI can be used pretty pervasively within Powershell Pipeworks.
By putting UseJQueryUI=$true within a Pipeworks manifest, JQueryUI will be used throughout the site.

Setting JQueryUITheme to a different value will attempt to grab a different theme from the Content distribution network. You can also set JQueryUITheme to 'Custom', and use a theme you create yourself on JQueryUI's Themeroller

JQueryUI is one of the JavaScript UI frameworks supported by Pipeworks. It is required in order to use New-Region -AsTab
]]>JQueryUI In Pipeworks/
NoHTML SitesStart-AutomatingWed, 04 Dec 2013 07:56:48 GMT HTML can be horrible.
Making most sites requires a fairly deep understanding of how HTML renders in various browsers, how CSS fits into the picture, which javascript framework to use, and how to put it all together. However, you can create fairly advanced sites and services in Pipeworks without knowing any HTML.

Since a PowerShell module doesn't need to contain any commands, you can make a simple NOHTML site by creating an empty module with a simple topic or two:

# Create a directory to contain the topicsNew-Item"$home\Documents\WindowsPowerShell\Modules\NoHTML\$(Get-Culture)\"-Force-ItemTypeDirectory|Out-Null</pre><pre># Put a sparse module manifest in the directory.# The only thing that's "really" required in a Pipeworks manifest is the version"@{ModuleVersion = '1.0'}"|Set-Content$home\Documents\WindowsPowerShell\Modules\NoHTML\NOHtml.psd1</pre><pre>"
Hello World
</pre>
<pre>
# This is important!
</pre>
<pre>
### This is less important
"|Set-Content$home\Documents\WindowsPowerShell\Modules\NoHTML\Hello_World.help.txt</pre><BR/><BR/><pre>Import-ModuleNoHTML-Force-PassThru|ConvertTo-ModuleService-Force

]]>NoHTML Sites/
Powerful Powershell FormattingStart-AutomatingWed, 04 Dec 2013 07:56:48 GMT As a language, PowerShell is full of interesting powers. One of the less understood, but more powerful, ones is the view system.

In PowerShell, you're constantly running into different types of data, so how you're exposed to this information means a lot.
Because of this, there is a very flexible types and formatting system in PowerShell.
You can define a view for any type of object, and, by default, PowerShell will show you every property that object has.

Pipeworks works the same way: You can let it display a table of properties on an object, or you can declare a view.

Also, just like PowerShell ships with views for types you're going to see a lot (like WMI classes or performance counters), Pipeworks ships with a lot of views for the types of objects you'll find on the web.

These sites keep common lists of property bags you can use, and the most common of these property bags are views included with Pipeworks.
]]>Powerful Powershell Formatting/
Making Tables With Out-HTMLStart-AutomatingWed, 04 Dec 2013 07:56:48 GMT
The example below renders a quick 'Person' object with Out-HTML.

To save money, let's not keep the instance around any longer than it needs to be. This is the joy of the cloud.

Get-EC2-Name$ServerName|Remove-EC2

]]>Managing Amazon Web Services With PowerShell Pipeworks/
A Simple StocktickerStart-AutomatingWed, 04 Dec 2013 07:56:48 GMT
PowerShell Pipeworks can be very great for creating software services out of information on the internet.

In this sample, we'll create a simple stock ticker that parses Yahoo Finance.

It's parsing the web page for a given stock. It uses Get-Web once to return HTML, and then calls Get-Web -Tag with that HTML to pull out specific CSS styles that I know contain information about the stock.

It's very important to note that the output object is given it's own type name, which lets us format the object however we'd like. The code that does this looks like so:

When you use Get-SecureSetting inside of a webpage, it looks for settings in the web.config file.

If you write your functions to use -ValueOnly, you can have the script work the same in the console as it does on the web.

$storageAccount=Get-SecureSetting'AzureStorageAccountName'-ValueOnly

]]>Scripting Securely with SecureSettings/
Getting GitItStart-AutomatingWed, 04 Dec 2013 07:56:48 GMT
Pipeworks 1.8 includes a lot of interesting little changes. One simple one is the inclusion of a new Pipeworks manifest section, GitIt.

GitIt tells Pipeworks to go collect content from GitHub. It will also make all pages within the module include the content from Git. For instance, this Pipeworks manifest would get the HTML5Shiv from GitHub

@{GitIt=@{"afarkas/HTML5Shiv/dist/html5shiv.js"="JS\html5shiv.js"}}

This will grab the latest version of three.js, the JavaScript 3D Framework, and create a sample page.

]]>Getting GitIt/
Using Azure Table Storage in PipeworksStart-AutomatingWed, 04 Dec 2013 07:56:48 GMT
Let's get started by getting the list of tables. To do this, we just use Get-AzureTable, and provide a -StorageAccount and -StorageKey.

You only need to do this once, afterwards, every other command will keep using the same -StorageAccount and -StorageKey.

You can also create psuedo objects with named and put them into Azure. The last typename is the only typename put in.

This allows you to quickly construct http://Schema.org items, or otherwise pair information with a view in PowerShell

$articleLink=New-ObjectPSObject-Property@{Name='Brevity is the Soul of Wit'DatePublished=[DateTime]'2/19/2012'Keyword='Quote, Irony'Url='http://wiki.answers.com/Q/What_does_%27brevity_is_the_soul_of_wit%27_mean'Description='Brevity may the Soul of Wit, but Polonius was never brief'}$articleLink.pstypenames.clear()$articleLink.pstypenames.add('http://Schema.org/Article')$articleLink|Set-AzureTable-TableName$tableName-PartitionKey'Articles'-RowKey("{0:x}"-f(Get-Random))

Because Get-Web can pull out Microdata from a website, this makes it simple to pull information from the web into azure tables

Remove-AzureTable has 3 parameters that are working behind the scenes to make this happen -TableName, -RowKey, and -PartitionKey
Each item is coming from the pipeline by property name. We can also use them at the command line:

Remove-AzureTable-TableName$tableName-PartitionKeyDefault-RowKey0

Remove-AzureTable can also clear out an entire table. It also has a nifty feature, -WhatIf, that would show us what we'd do if we removed a thing

Remove-AzureTable-TableName$tableName-WhatIf

Before we remove this table, let's replicate it to another one.

Because Set-AzureTable can take parameters from the pipeline by property name, it can transmute the parameter info to copy the data.

OpenGraph is an interesting technology from Facebook that documents objects and their relationships.

It turns all of Facebook via a gigantic RESTful JSON web service.

To interact with this with Powershell Pipeworks, simply use the -AsJson parameter from Get-Web
This example gets information about Powershell Pipeworks.

Get-Web-Url"https://graph.facebook.com/250363831747570"-AsJson

OpenGraph information can also be embedded within a web page, and extracted directly from that page.

If a page has OpenGraph data, it often contains a helpful name, image, description.

This example also shows using the -UseWebRequest parameter, which will use a simple HttpWebRequest object to communicate. By default, Get-Web will try to download things with the xmlHTTP object, which is faster and can impersonate a logon within Internet Explorer.

Get-Web-Url"http://imdb.com/"-OpenGraph-UseWebRequest

You can use the -Parameter parameter to call a web service. For instance, this sort script uses Get-Web to call Write-ScriptHTML remotely

]]>Get-Web Content From Anywhere/
Implicit Texting With TwilioStart-AutomatingWed, 04 Dec 2013 07:56:48 GMTTwilio. So well, in fact, that you don't really have to think about it. You just have to think about how your cmdlet works.

Every command that you expose as a web service implicitly can be talked to via text. The way it works is pretty simple, but can be pretty dangerous if you let the wrong command work.

Text messages from Twilio come with a number of request parameters. Any of these parameters that are found on your function get passed in the value Twilio sends you. Any other parameters get passed in positionally.

When the output comes back from the command as text, it's sent directly to the user. If it's anything else, each property of the object is show on a different line of the text message.
]]>Implicit Texting With Twilio/