-
Notifications
You must be signed in to change notification settings - Fork 14
/
Pipeworks.psm1
370 lines (275 loc) · 22.3 KB
/
Pipeworks.psm1
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
param([switch]$clean)
#region PowerShell tools
. $psScriptRoot\Get-FunctionFromScript.ps1
. $psScriptRoot\Write-PowerShellHashtable.ps1
. $psScriptRoot\Import-PSData.ps1
. $psScriptRoot\Export-PSData.ps1
#endregion
#region Pipeworks General Tools
. $psScriptRoot\Get-Web.ps1
. $psScriptRoot\Get-PipeworksManifest.ps1
. $psScriptRoot\New-PipeworksManifest.ps1
#endregion
#region Login System Commands
. $psScriptRoot\Get-Person.ps1
. $psScriptRoot\Join-Website.ps1
. $psScriptRoot\Confirm-Person.ps1
. $psScriptRoot\Add-Interaction.ps1
#endregion
#region Core Web Commands
. $psScriptRoot\Invoke-WebCommand.ps1
. $psScriptRoot\ConvertFrom-Markdown.ps1
. $psScriptRoot\Compress-Data.ps1
. $psScriptRoot\Expand-Data.ps1
. $psScriptRoot\Get-Walkthru.ps1
. $psScriptRoot\Get-WebConfigurationSetting.ps1
. $psScriptRoot\Get-WebInput.ps1
. $psScriptRoot\New-Region.ps1
. $psScriptRoot\New-RssItem.ps1
. $psScriptRoot\New-WebPage.ps1
. $psScriptRoot\Out-HTML.ps1
. $psScriptRoot\Out-RSSFeed.ps1
. $psScriptRoot\Request-CommandInput.ps1
. $psScriptRoot\Send-Email.ps1
. $psScriptRoot\Write-WalkthruHtml.ps1
. $psScriptRoot\Write-Ajax.ps1
. $psScriptRoot\Write-Css.ps1
. $psScriptRoot\Write-Host.ps1
. $psScriptRoot\Write-Link.ps1
. $psScriptRoot\Write-ScriptHtml.ps1
#endregion Core Web Commands
#region ASP & HTML code Generators
. $psScriptRoot\ConvertFrom-InlinePowerShell.ps1
# . $psScriptRoot\ConvertTo-CommandService.ps1
. $psScriptRoot\ConvertTo-ModuleService.ps1
. $psScriptRoot\Write-AspNetScriptPage.ps1
#endregion
#region Mini Servers and their deploy tools
. $psScriptRoot\Start-PSNode.ps1
. $psScriptRoot\Open-Port.ps1
. $psScriptRoot\Close-Port.ps1
. $psScriptRoot\Install-PSNode.ps1
#endregion Mini Servers and their deploy tools
#region Daemons
. $psScriptRoot\Out-Daemon.ps1
. $psScriptRoot\Remove-Daemon.ps1
. $psScriptRoot\Watch-Daemon.ps1
#endregion Daemons
#region Azure Tools
. $psScriptRoot\Add-AzureRole.ps1
. $psScriptRoot\Add-AzureLocalResource.ps1
. $psScriptRoot\Add-AzureSetting.ps1
. $psScriptRoot\Add-AzureStartupTask.ps1
. $psScriptRoot\Add-AzureWebSite.ps1
. $psScriptRoot\New-AzureServiceDefinition.ps1
. $psScriptRoot\Out-AzureService.ps1
. $psScriptRoot\Publish-AzureService.ps1
. $psScriptRoot\Get-Blob.ps1
. $psScriptRoot\Import-Blob.ps1
. $psScriptRoot\Export-Blob.ps1
. $psScriptRoot\Remove-Blob.ps1
#endregion Azure Tools
. $psScriptRoot\Get-Email.ps1
. $psScriptRoot\Send-TextMessage.ps1
. $psScriptRoot\Get-TextMessage.ps1
. $psScriptRoot\Get-PhoneCall.ps1
. $psScriptRoot\Send-PhoneCall.ps1
. $psScriptRoot\Out-Zip.ps1
. $psScriptRoot\Expand-Zip.ps1
#region Storage Tools
. $psScriptRoot\Write-CRUD.ps1
. $psScriptRoot\Show-WebObject.ps1
#endregion Storage Tools
#region SQL Tools
. $psScriptRoot\Select-SQL.ps1
. $psScriptRoot\Add-SQLTable.ps1
. $psScriptRoot\Get-SQLTable.ps1
. $psScriptRoot\Update-SQL.ps1
. $psScriptRoot\Remove-SQL.ps1
. $psScriptRoot\New-SQLDatabase.ps1
. $psScriptRoot\Import-StoredProcedure.ps1
#endregion SQL Tools
#region Datatables
. $psScriptRoot\New-DataTable.ps1
. $psScriptRoot\ConvertTo-DataTable.ps1
. $psScriptRoot\Import-DataTable.ps1
. $psScriptRoot\Export-DataTable.ps1
. $psScriptRoot\Select-DataTable.ps1
. $psScriptRoot\Update-DataTable.ps1
#endregion Datatables
#region Secure Scripting Tools
. $psScriptRoot\Add-SecureSetting.ps1
. $psScriptRoot\Get-SecureSetting.ps1
. $psScriptRoot\Remove-SecureSetting.ps1
#endregion Secure Scripting Tools
#region FTP Tools
. $psScriptRoot\Get-FTP.ps1
. $psScriptRoot\Push-FTP.ps1
#endregion FTP Tools
#region Deployment Tools
. $psScriptRoot\Add-Deployment.ps1
. $psScriptRoot\Get-Deployment.ps1
. $psScriptRoot\Import-Deployment.ps1
. $psScriptRoot\Switch-TestDeployment.ps1
. $psScriptRoot\Publish-Deployment.ps1
. $psScriptRoot\Push-Deployment.ps1
. $psScriptRoot\Remove-Deployment.ps1
. $psScriptRoot\Wait-Deployment.ps1
#endregion Deployment Tools
#region Web Services
. $psScriptRoot\Get-Paid.ps1
. $psScriptRoot\Get-Translation.ps1
. $psScriptRoot\Find-Factual.ps1
. $psScriptRoot\Invoke-Office365.ps1
. $psScriptRoot\Search-WolframAlpha.ps1
. $psScriptRoot\Search-Engine.ps1
#endregion Web Services
#region Web Frameworks
. $psScriptRoot\Get-Bootstrapped.ps1
. $psScriptRoot\Use-Less.ps1
#endregion Web Frameworks
#region Kitchen Sink
. $psScriptRoot\Get-Hash.ps1
. $pSScriptRoot\New-RDPFile.ps1
. $pSScriptRoot\Start-At.ps1
. $psScriptRoot\Resolve-Location.ps1
. $psScriptRoot\Use-Schematic.ps1
. $psScriptRoot\ConvertTo-ServiceUrl.ps1
. $psScriptRoot\Publish-WebSite.ps1
. $psScriptRoot\test-w3c.ps1
. $psScriptRoot\Get-WebTemplateEditableRegion.ps1
. $psScriptRoot\Select-WMI.ps1
. $psScriptRoot\Update-WMI.ps1
#endregion Kitchn Sink
#region Data & Parallelism
. $psScriptRoot\Invoke-Parallel.ps1
. $psScriptRoot\Start-MapReduce.ps1
#endregion Data & Parallelism
#region Initialize Shared Data
$script:FunctionsInEveryRunspace = 'ConvertFrom-Markdown', 'Confirm-Person', 'Get-Person', 'Get-Web', 'Get-PipeworksManifest', 'Get-WebConfigurationSetting', 'Get-FunctionFromScript', 'Get-Walkthru',
'Get-WebInput', 'New-RssItem', 'Invoke-WebCommand', 'Out-RssFeed', 'Request-CommandInput', 'New-Region', 'New-WebPage', 'Out-Html',
'Write-Css', 'Write-Host', 'Write-Link', 'Write-ScriptHTML', 'Write-WalkthruHTML', 'Write-PowerShellHashtable', 'Compress-Data',
'Expand-Data', 'Import-PSData', 'Export-PSData', 'ConvertTo-ServiceUrl', 'Get-SecureSetting', 'Search-Engine', 'Get-Hash'
#endregion
Add-Type -AssemblyName System.Web, System.Xml.Linq
$linq = [Reflection.Assembly]::LoadWithPartialName("System.Linq")
#region Compile or Import Azure Table Storage Cmdlets
$dllPath = "$psScriptRoot\AzureTableStorage.CLR$($psVersionTable.CLRVersion).dll"
$m = if ($Clean -or (-not (Test-Path $dllPath))){
$files = Get-ChildItem $psScriptRoot\CSharp -Filter *Azure*.cs
$fileContents = foreach ($f in $files) {
[IO.File]::ReadAllText($f.Fullname)
}
$languageVersion = @{Language='CSharpVersion3'}
if ($psVersionTable.CLRVersion -ge '4.0') {
$languageVersion = @{}
}
if ($clean) {
$languageVersion.OutputAssembly = "$dllPath"
}
$linqLocation = [System.Linq.IQueryable].Assembly.Location
$xlinqLocation = [System.Xml.Linq.XNamespace].Assembly.Location
$systemWebLocation = Add-Type -AssemblyName System.Web -PassThru | Select-Object -ExpandProperty Assembly -Unique | Select-Object -ExpandProperty Location -Unique
$refs =
if ($pslanguageTable.CLRVersion -lt '4.0') {
'System.Xml', 'System.Net', $xlinqLocation,([Management.Automation.Languageprimitives].Assembly.Location), $systemWebLocation -ne '' | Select-Object -Unique
} else {
'System.Xml', 'System.Net', $linqLocation, $xlinqLocation,([Management.Automation.Languageprimitives].Assembly.Location), $systemWebLocation -ne '' | Select-Object -Unique
}
$m = Add-Type @languageVersion -ReferencedAssemblies $refs -TypeDefinition "
$($fileContents -join ([Environment]::NewLine))
" -PassThru |
Select-Object -ExpandProperty Assembly |
Import-Module -PassThru
if ($compilationIssues) {
$compilationIssues | Out-String | Write-Debug
}
} else {
Import-Module $dllPath -PassThru
}
#endregion
#region EC2
if (-not ('Amazon.Runtime.BasicAWSCredentials' -as [type])) {
"$env:ProgramFiles", "${env:ProgramFiles(x86)}" -ne "" |
Get-ChildItem -Filter 'AWS SDK for .NET' |
Get-ChildItem -Filter 'bin' |
Get-ChildItem -Filter *.dll |
Select-Object -First 1 |
Import-Module -Name {$_.Fullname }
}
$clientTypes = 'Amazon.Route53.AmazonRoute53Client',
'Amazon.ElasticMapReduce.AmazonElasticMapReduceClient',
'Amazon.CloudFront.AmazonCloudFrontClient',
'Amazon.ElasticLoadBalancing.AmazonElasticLoadBalancingClient',
'Amazon.SimpleNotificationService.AmazonSimpleNotificationServiceClient',
'Amazon.EC2.AmazonEC2Client',
'Amazon.SimpleDB.AmazonSimpleDBClient',
'Amazon.ElasticBeanstalk.AmazonElasticBeanstalkClient',
'Amazon.DynamoDB.AmazonDynamoDBClient',
'Amazon.IdentityManagement.AmazonIdentityManagementServiceClient',
'Amazon.AutoScaling.AmazonAutoScalingClient',
'Amazon.SQS.AmazonSQSClient',
'Amazon.CloudFormation.AmazonCloudFormationClient',
'Amazon.S3.AmazonS3Client' -as [type[]]
$script:AmazonAccessKeySettingName = 'AwsAccessKeyId'
$script:AmazonSecretAccessKeySettingName = 'AmazonSecretAccessKey'
$script:AmazonAccessKey = Get-SecureSetting -Name $script:AmazonAccessKeySettingName -ValueOnly
$script:AmazonSecretAccessKey = Get-SecureSetting -Name $script:AmazonSecretAccessKeySettingName -ValueOnly
if ($script:AmazonAccessKey -and $script:AmazonSecretAccessKey -and ('Amazon.Runtime.BasicAWSCredentials' -as [type])) {
$script:AwsCredential = New-Object Amazon.Runtime.BasicAWSCredentials $script:AmazonAccessKey, $script:AmazonSecretAccessKey
}
if ($script:AwsCredential) {
$script:AwsConnections = $clientTypes |
ForEach-Object -Begin {
$Connections = @{}
} -process {
$connections[$_.Name.Replace('Amazon', '').Replace('Client','')] =
New-Object $_.Fullname $script:AwsCredential.GetCredentials().AccessKey, $script:AwsCredential.GetCredentials().ClearSecretKey
} -end {
New-Object PSObject -Property $connections
}
}
. $psScriptRoot\Set-AwsConnectionInfo.ps1
if ($script:AwsConnections) {
. $psScriptRoot\Add-EC2.ps1
. $psScriptRoot\Get-EC2.ps1
. $psScriptRoot\Reset-EC2.ps1
. $psScriptRoot\Get-Ami.ps1
. $psScriptRoot\Get-EC2InstancePassword.ps1
. $psScriptRoot\Get-EC2AvailabilityZone.ps1
. $psScriptRoot\Get-EC2SecurityGroup.ps1
. $psScriptRoot\Get-EC2KeyPair.ps1
. $psScriptRoot\Open-EC2Port.ps1
. $psScriptRoot\Remove-EC2.ps1
. $psScriptRoot\Remove-EC2KeyPair.ps1
. $psScriptRoot\Remove-EC2SecurityGroup.ps1
. $psScriptRoot\Enable-EC2Remoting.ps1
. $psScriptRoot\Wait-EC2.ps1
. $psScriptRoot\Connect-EC2.ps1
. $psScriptRoot\Invoke-EC2.ps1
} else {
}
Set-Alias cms ConvertTo-ModuleService
Set-Alias paz Publish-AzureService
Set-Alias Publish-WebService Publish-WebSite
Set-Alias pws Publish-WebSite
Set-Alias ieo365 Invoke-Office365
Set-Alias wasp Write-AspDotNetScriptPage
Set-Alias psnode Start-PSNode
Set-Alias ohtml Out-HTML
Set-Alias markdown ConvertFrom-Markdown
Set-Alias gweb Get-Web
Set-Alias sql Select-SQL
Set-Alias iwc Invoke-WebCommand
Set-Alias impsd1 Import-PSData
Set-Alias expsd1 Export-PSData
Set-Alias imblob Import-Blob
Set-Alias exblob Export-Blob
Set-Alias text Send-TextMessage
Set-Alias txt Send-TextMessage
Set-Alias call Send-PhoneCall
Set-Alias gblob Get-Blob
Set-Alias rmblob Remove-Blob
Set-Alias Remove-Service -Value Remove-Daemon
Export-ModuleMember -Function * -Alias * -Cmdlet *
#endregion