BackgroundThe qbo.ps1 Powershell script is a cmdlet library for managing QBO deployment tasks. High level features include management of:
In order to leverage this script, you should have Powershell 4 installed:
Use Case: Create a Web Deploy Package for Easy Installation on IISIn this use case, we will create a web deploy package (.zip file) that can be imported into IIS, creating our QBO website for us. For this example, we'll build the package from trunk, and include the HelpDesk theme. You can instead build from a branch by specifying a -sourcePath parameter to the qbo.Core folder that is part of your branch (e.g. -sourcePath "e:\source\branches\qbo\201409\qbo.Core").
# Load the standard QBO cmdlets Import-Module .\qbo.ps1 # Create a package file called "HelpDesk201410.zip" with the core applications New-qboWebPackage -apps "Application,Accounting,Attachment,Contact,Decision,Heartbeat,Import,Logging,Message,Process,Report,Score,Security,Credit,Debt,Mortgage,SkipTrace" -packageName "HelpDesk201410.zip" -pubfile "UAT.pubxml" -Verbose # Add in plugins New-qboWebPackage -plugins "Amazon,ABCPDF,Adobe,Aspose,AuthorizeNet,Form,Google,Quandis,Rebex,Service.Http,Service.InboundService,qbo.HTML,qbo.Queue.MSSQL,DbMaintenance, RemoteQboService " - packageName " HelpDesk201410 .zip" -pubfile "UAT.pubxml" -Verbose# Add in a theme New-qboWebPackage -theme "HelpDesk" - packageName " HelpDesk201410 .zip" -pubfile "UAT.pubxml" -Verbose# Write the package to SVN, so the target servers can download them Write-qboSvnFile .\Package\Packages\HelpDesk201410.zip -comment "Created a new Help Desk site package" Use Case: Install A New Website On An Existing ServerIn this use case, we will create help.quandis.net on A1P1QBO.
Import-Module .\qbo.ps1
# When connecting to a remote machine, PS required that you explicitly trust that machine. # For a machine called u1qbs, this is done via: winrm s winrm/config/client '@{TrustedHosts="u1qbs"}' # By default, Open-qboSession ... -ensureHost will ensure *.quandis.net is part of your machine's winrm configuration. # Include '.quandis.net' in all machine connections; if you machine is named u1qbs, create a host header for u1qbs.quandis.net to the private IP. Open-qboSession "a1p3qbo.quandis.net" -ensureScript -Verbose
Get-PSSession | % {invoke-command -Session $_ -ScriptBlock { Confirm-qboSite -site "help.quandis.net" }} Get-PSSession | % {invoke-command -Session $_ -ScriptBlock { Publish-qboWebPackage -packageUrl "HelpDesk201410.zip" -appName "help.quandis.net" }} Get-PSSession | % {invoke-command -Session $_ -ScriptBlock { Confirm-qboWebSetup -site "help.quandis.net" }}
# Create a1p3qbohelp.quandis.net (in addition to help.quandis.net) so we can test the a1p3qbo box directly via its IP address Get-PSSession | % {invoke-command -Session $_ -ScriptBlock { New-qboSiteAlias -alias "a1p3qbo" -ssl }}
# Grant full control on the website folder to the iis user (this should happen as part of Confirm-qboSite, but if you skipped that step for an existing site, use this.) Get-PSSession | % {invoke-command -Session $_ -ScriptBlock { Set-qboSiteAcl -site 'help.quandis.net' }}
# Clean up the package file Delete-qboSvnFile .\Package\Packages\UATQBS-12.04.14-1.zip -comment "Deployment Complete" Use Case: Ad-Hoc Deployments to Local or DEVThe New-qboWebPackage will use whatever .pubxml file you wish by specifying the -pubfile parameter. If you wish to deploy a handful of projects to your local machine, create a localhost.pubxml file using FileSystem (or WebDeploy) to publish, instead of Package.
New-qboWebPackage -apps "Application,Attachment" -plugins "Amazon,Rebex" -pubfile .\localhost.pubxml -Verbose set-qboDefault "AllApps" "Application,Accounting,Attachment,Contact,Decision,Heartbeat,Import,Logging,Message,Process,Report,Score,Security,Credit,Debt,Mortgage,SkipTrace" set-qboDefault "AllPlugins" "Amazon,Rebex" new-qboWebPackage -pubfile .\localhost.pubxml -apps (get-qboDefault "AllApps") QBO Code DeploymentConfirm-qboWebSetup This will ensure a website is properly configured to run QBO by ensuring required .config files are present. This is typically used when first setting up a website, and will verify the existence of:
Confirm-qboDbUser This will create a server and database login, if the specified login does not exists. Example: Confirm-qboDbUser -dbServer TAURUS2 -dbName client.quandis.net -dbUser client.login@quandis.net -dbPassword AAdf23!kj New-qboInstance
This will create a new AWS instance to be used as a web or application server. Parameters include:
Get-qboInstances
This will get a list of AWS EC2 instances, filtered by a string. Parameters include:
Example:
get-qboinstances "qbo" This will return all AWS EC2 instances with 'qbo' somewhere in the 'name' tag.
IIS ManagementConfirm-qboSite This will create a website if it does not already exist, including:
Example: Confirm-qboSite -site "client.quandis.net" -ssl Set-qboConnection
This will modify a connection string in /Config/ConnectionStrings.config in a target website. Parameters are:
You can modify the entire connection string, or just one part. Connection strings are in the format:
Data Source={dataSource};Initial Catalog={database};Connect Timeout={timeout};Trusted_Connection=false;UID={username};PWD={password};Application Name={appName} Examples:
// Set a connection string (-name will default to "qbo.Default") Set-qboConnection -site forms.quandis.net -cs "Data Source={mydbserver};Initial Catalog=forms.quandis.net;Connect Timeout=120;Trusted_Connection=false;UID=login@quandis.net;PWD={...};Application Name=forms.quandis.net" // Change the app name used by a machine (so SQL profiler shows which machine is making a DB call) Set-qboConnection -site forms.quandis.net -appName "A1P4Forms" Copy-qboSite
This will create a new target website, copy the Bin and Config folders from the source, and create a virtual directory for all other folders in the source.
Examples:
// Copy the forms.quandis.net site to slsforms.quandis.net, so we can customize the UI Copy-qboSite "forms.quandis.net" "slsforms.quandis.net" Set-qboConnection -site slsforms.quandis.net -appName "A1P4SlsForms" Write-qboIISLogs
This will use LogParser.exe to copy IIS log files to a SQL server. The cmdlet is smart enough to query the target database for the last log written from a machine, and only write log entries that occur after that last log date-time stamp. If there are no previous log entries from the machine, the last 3 days worth of logs will be written by default; this can be overridden with the -from parameter.
Note that if LogParser is not installed on the machine, the cmdlet will download and install it.
Parameters:
Example:
// Connect to the SLS PROD Open-qboSession -targets "a1p1qbo.quandis.net,a1p2qbo.quandis.net" // For each connection, copy IIS logs to the support.quandis.com database Get-PSSession | % { Invoke-Command -Session $_ -ScriptBlock { Write-qboIISLogs -machine $_.ComputerName -dbserver 10.11.101.125 -dbname support.quandis.com } } Set-qboUser
Creates a Windows local user, sets their password, and adds them to the Administrators group.
Examples:
// Create user jdoe with a password YoYoMa Set-qboUser jdoe YoYoMa // Connect to a1p1qbo and a1p4qbo, ensuring your client trusts *.quandis.net and *.quandis.com. Loads the qbo.ps1 module on the target machine. Open-qboSession "a1p1qbo.quandis.net,a1p4qbo.quandis.net" -ensureHost // Set user jdoe password to YoYoMa on multiple machine at once Get-PSSession | % {invoke-command -Session $_ -ScriptBlock { Set-qboUser jdoe YoYoMa }} Remove-qboUser
Removes a Windows local user.
Get-qboSvnFile
Downloads a file from SVN to a target path on the local machine.
Examples:
// Download the Queue Service MSI Get-qboSvnFile -path "Trunk/qbo.3/Installation/qbo.QueueService.2.3.0.x64.msi" -target "c:\program files (x86)\Quandis" RemotingPowershell remoting allows you to execute scripts on a remote machine.
Troubleshooting
Error:
New-PSSession : [a1p1qbo.quandis.net] Connecting to remote server a1p1qbo.quandis.net failed with the following error message : The WinRM client cannot process the
request. If the authentication scheme is different from Kerberos, or if the client computer is not joined to a domain, then HTTPS transport must be used or the
destination machine must be added to the TrustedHosts configuration setting. Use winrm.cmd to configure TrustedHosts. Note that computers in the TrustedHosts list might
not be authenticated. You can get more information about that by running the following command: winrm help config. For more information, see the
about_Remote_Troubleshooting Help topic.
Solution:
On your client (development machine), ensure you trust the server you are connecting to by adding the host to the TrustedHosts attribute in WinRM. This can be done by calling:
Open-qboSession -target a1p1qbo.quandis.net -ensureHost Then, on the server, ensure Powershell Remoting is enabled:
enable-psremoting -force HistoryPrerequisites:
Source > qbo.3 > Publish contains several files relevant to deployments, including the following PowerShell scripts:
IIS Deployments: deploy.ps1Open Powershell, and navigate to the folder containing deploy.ps1 (usual your SVN > qbo.3 > Publish folder):
// Deploy all core apps and plugins to an IIS site using localhost.pubxml file PS E:\source\qbo.3\publish> .\deploy.ps1 -site localhost -allapps -allplugins // Deploy just the Accounting and Security modules to an IIS site using localhost.pubxml file PS E:\source\qbo.3\publish> .\deploy.ps1 -site localhost -apps @("Accounting", "Security") // Deploy all Amazon plugins to an IIS site using uatadr.pubxml file PS E:\source\qbo.3\publish> .\deploy.ps1 -site uatadr -plugins "Amazon" // Deploy just the Support theme to an IIS site using a impdev.pubxml file; note a password is required if the pubxml file uses MSDeploy (Web Deployment) PS E:\source\qbo.3\publish> .\deploy.ps1 -site impdev -password {Your NT/IIS account password} -themes "Support" AWS Server ConfigurationOpen Powershell, and navigate to the folder containing aws.ps1:
// Set your AWS credentials (one-time) Set-AWSCredentials -AccessKey {your access key} -SecretKey {your secret key} -StoreAs default // Create a new web VM called A1U2Forms based on all defaults. PS E:\source\qbo.3\publish> .\aws.ps1 -name "A1U2Forms" // Create a new VM called A1U3Forms based on the QBO Standard AMI in the 10.0.4.0 subnet PS E:\source\qbo.3\publish> .\aws.ps1 -name "A1U3Forms" -ami " QBO Standard" -subnet "4.0" Parameters:
Actions taken:
The rest of this post is still unstructured notes on what we've done so far.
Example db.ps1 usage:
Parameters for db.ps1 include:
Creating a new Database:
Install all tables and user-defined functions from source:
Set up an admin account with the password 'Password':
Running MSBuild:
Setting up IIS:
|
Quandis Business Objects 3 > QBO 3 Blog >