-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPractice-Script.ps1
More file actions
101 lines (92 loc) · 2.97 KB
/
Copy pathPractice-Script.ps1
File metadata and controls
101 lines (92 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<#
.NOTES
===========================================================================
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2016 v5.2.118
Created on: 4/1/2016 5:52 PM
Created by: DevinL
Organization: SAPIEN Technologies, Inc.
Filename: Practice-Script.ps1
===========================================================================
.DESCRIPTION
A description of the file.
#>
function Build-Item
{
param (
$ProjectDir,
$PSBuildOpts
)
$PSBuildPath = Find-Install
Write-Verbose $PSBuildPath
$PSBuildSettingsFile = Get-ChildItem -Path $ProjectDir -Filter *.psbuild | ForEach-Object { $_.FullName }
if (($PSBuildSettingsFile -ne $null) -and (Test-Path $PSBuildSettingsFile))
{
$Builder = New-Object System.Diagnostics.Process
$Builder.StartInfo.WorkingDirectory = $ProjectDir
$Builder.StartInfo.FileName = $PSBuildPath
$Builder.StartInfo.Arguments = "/$PSBuildOpts $PSBuildSettingsFile"
$Builder.StartInfo.UseShellExecute = $false
$Builder.StartInfo.RedirectStandardOutput = $true
if ($Builder.Start())
{
[String]$Output = $Builder.StandardOutput.ReadToEnd()
}
Write-Output $Output
}
else
{
Write-Warning "No psbuild file could be located."
Write-Warning "If this is your first time building an exe, do so from PowerShell Studio or PrimalScript first."
}
}
function Find-Install
{
try
{
$RegPath = 'HKLM:\SOFTWARE\SAPIEN Technologies, Inc.\'
$SPSPath = Get-ChildItem $RegPath -ErrorAction Stop | Select-Object PSPath | ForEach-Object { if ($_.PSPath -match "PowerShell Studio") { $_.PSPath } }
$PSRPath = Get-ChildItem $RegPath -ErrorAction Stop | Select-Object PSPath | ForEach-Object { if ($_.PSPath -match "PrimalScript") { $_.PSPath } }
if (($SPSPath -ne $null) -and (Test-Path $SPSPath))
{
$PSBuildPath = Split-Path (Get-ItemProperty $SPSPath).Path -Parent
}
elseif (($PSRPath -ne $null) -and (Test-Path $PSRPath))
{
$PSBuildPath = Split-Path (Get-ItemProperty $PSRPath).Path -Parent
}
else
{
Write-Warning 'You do not have PowerShell Studio or PrimalScript installed.'
Write-Warning 'Please install one or the other to continue.'
}
$PSBuildPath += "\psbuild.exe"
Resolve-Path $PSBuildPath
}
catch [System.Management.Automation.ItemNotFoundException] {
Write-Warning 'You do not have any SAPIEN Software installed.'
Write-Warning 'Please install PowerShell Studio or PrimalScript and try again.'
}
}
function Invoke-Deploy
{
param
(
[Parameter(Mandatory = $true,
Position = 0)]
[String]$ProjectDir
)
try
{
$ProjectDir = Resolve-Path $ProjectDir
Build-Item -ProjectDir $ProjectDir -PSBuildOpts "DEPLOY"
}
catch [System.Management.Automation.ItemNotFoundException] {
Write-Warning 'The specified directory does not exist.'
Write-Debug 'ItemNotFoundException'
}
catch [System.Management.Automation.ParameterBindingException] {
Write-Warning 'The specified directory does not exist.'
Write-Debug 'ParameterBindingException'
}
}
Invoke-Deploy 'DD'