(ConvertFrom-Markdown -Markdown '# Getting Started with Pipeworks ') + (Write-Link 'http://www.youtube.com/watch?v=cR2koin9QNA') | New-Region -LayerId PlayerRegion -Style @{ "Margin-Left" = '16%' "Margin-Right" = '16%' "Margin-Top" = '12%' 'Text-Align' = "center" } | New-WebPage -Title 'Pipeworks Quickstart' -Css @{ Body = @{ 'Background-color' = '#fafafa' 'Font-Family' = 'Segoe UI' } }
# 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 -ItemType Directory -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 command New-PipeworksManifest -Name SayHello -WebCommand @{ "Show-HelloMessage" = @{ FriendlyName = 'Say Hello' } } | Set-Content "$modulePath\SayHello.Pipeworks.psd1" # To create your web service, run the following command: Import-Module SayHello -Force -PassThru | ConvertTo-ModuleService -Force # You can now navigate to http://localhost/SayHello and make it greet you
# 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 -ItemType Directory -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 -Name ShowMe -WebCommand @{ "Show-Me" = @{ RequireLogin = $true RunWithoutInput = $true FriendlyName = '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-Module ShowMe -Force -PassThru | ConvertTo-ModuleService -AsIntranetSite -Port 222 -Force Start-Process http://localhost:222/