From cf293c00eb191f94ec6aabbf0f6ed81d251f91de Mon Sep 17 00:00:00 2001 From: Alex Sarafian Date: Tue, 31 Jan 2017 14:38:42 +0100 Subject: [PATCH 1/5] Bumped version to 1.1 (#5) --- CHANGELOG.md | 2 ++ Source/Modules/ISHServer/metadata.ps1 | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2061fc5..b0cf7d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +**1.1** + **1.0** - Split from [ISHBootstrap](https://github.com/Sarafian/ISHBootstrap). diff --git a/Source/Modules/ISHServer/metadata.ps1 b/Source/Modules/ISHServer/metadata.ps1 index c43151f..816552b 100644 --- a/Source/Modules/ISHServer/metadata.ps1 +++ b/Source/Modules/ISHServer/metadata.ps1 @@ -15,5 +15,5 @@ #> <#PSScriptInfo -.VERSION 1.0 +.VERSION 1.1 #> \ No newline at end of file From 2b067788255cedcb2228c42c52adb32d633ae432 Mon Sep 17 00:00:00 2001 From: Alex Sarafian Date: Tue, 31 Jan 2017 15:03:49 +0100 Subject: [PATCH 2/5] #4 Upgraded SDLDevTools (#6) --- Automation/Pester/Test-SDLHeaders.Tests.ps1 | 2 +- .../0.1/Test-SDLOpenSourceHeader.ps1 | 96 ----------- .../{0.1 => 0.2}/Get-SDLOpenSourceHeader.ps1 | 14 +- .../Get-SDLOpenSourceHeaderFormat.ps1 | 0 .../{0.1 => 0.2}/PSGetModuleInfo.xml | Bin 10682 -> 10660 bytes .../SDLDevTools/{0.1 => 0.2}/SDLDevTools.psm1 | 2 +- .../{0.1 => 0.2}/Set-SDLOpenSourceHeader.ps1 | 0 .../0.2/Test-SDLOpenSourceHeader.ps1 | 158 ++++++++++++++++++ 8 files changed, 171 insertions(+), 101 deletions(-) delete mode 100644 Tools/Modules/SDLDevTools/0.1/Test-SDLOpenSourceHeader.ps1 rename Tools/Modules/SDLDevTools/{0.1 => 0.2}/Get-SDLOpenSourceHeader.ps1 (84%) rename Tools/Modules/SDLDevTools/{0.1 => 0.2}/Get-SDLOpenSourceHeaderFormat.ps1 (100%) rename Tools/Modules/SDLDevTools/{0.1 => 0.2}/PSGetModuleInfo.xml (93%) rename Tools/Modules/SDLDevTools/{0.1 => 0.2}/SDLDevTools.psm1 (98%) rename Tools/Modules/SDLDevTools/{0.1 => 0.2}/Set-SDLOpenSourceHeader.ps1 (100%) create mode 100644 Tools/Modules/SDLDevTools/0.2/Test-SDLOpenSourceHeader.ps1 diff --git a/Automation/Pester/Test-SDLHeaders.Tests.ps1 b/Automation/Pester/Test-SDLHeaders.Tests.ps1 index b35ad93..cbf0179 100644 --- a/Automation/Pester/Test-SDLHeaders.Tests.ps1 +++ b/Automation/Pester/Test-SDLHeaders.Tests.ps1 @@ -16,7 +16,7 @@ $sourcePath=Resolve-Path "$PSScriptRoot\..\.." -Import-Module "$sourcePath\Tools\Modules\SDLDevTools\0.1\SDLDevTools.psm1" -Force +Import-Module "$sourcePath\Tools\Modules\SDLDevTools" -Force # Must convert to array of hash to drive the It -Testcases parameter $filesToValidate=@() diff --git a/Tools/Modules/SDLDevTools/0.1/Test-SDLOpenSourceHeader.ps1 b/Tools/Modules/SDLDevTools/0.1/Test-SDLOpenSourceHeader.ps1 deleted file mode 100644 index 4bc703b..0000000 --- a/Tools/Modules/SDLDevTools/0.1/Test-SDLOpenSourceHeader.ps1 +++ /dev/null @@ -1,96 +0,0 @@ -<# -# Copyright (c) 2014 All Rights Reserved by the SDL Group. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#> - -Function Test-SDLOpenSourceHeader { - param( - [Parameter(Mandatory=$true,ParameterSetName="Folder")] - [string]$FolderPath, - [Parameter(Mandatory=$true,ParameterSetName="File")] - [string]$FilePath, - [Parameter(Mandatory=$false,ParameterSetName="File")] - [Parameter(Mandatory=$false,ParameterSetName="Folder")] - [switch]$PassThru=$false - ) - begin { - . $PSScriptRoot\Get-SDLOpenSourceHeader.ps1 - . $PSScriptRoot\Get-SDLOpenSourceHeaderFormat.ps1 - } - process { - switch($PSCmdlet.ParameterSetName) - { - 'Folder' { - Get-ChildItem $FolderPath -Filter "*.*" -Recurse -File | ForEach-Object { - if(-not ($_.FullName)) - { - continue - } - Test-SDLOpenSourceHeader -FilePath ($_.FullName) -PassThru:$PassThru - } - } - 'File' { - Write-Debug "Calculating format for $FilePath" - $fileFormat=Get-SDLOpenSourceHeaderFormat -FilePath $FilePath - if(-not $fileFormat) - { - Write-Warning "Skipped $FilePath" - break - } - Write-Debug "Testing header for $FilePath" - $header = Get-SDLOpenSourceHeader -Format $fileFormat - $content=Get-Content $FilePath - - $hash=[ordered]@{ - FilePath=$FilePath - Format=$fileFormat - Error=$null - } - if($content.Count -lt $header.Count) - { - $hash.Error="Line count less than header" - } - else - { - for($i=0;$i -lt $header.Count;$i++) - { - if($header[$i] -ne $content[$i]) - { - $hash.Error="Mismatch on line $($i+1)" - break - } - } - } - $hash.IsValid=$hash.Error -eq $null - Write-Verbose "Tested header for $FilePath" - if($PassThru) - { - New-Object -TypeName PSObject -Property $hash - } - else - { - if(-not $hash.IsValid) - { - Write-Error "Failed for $FilePath because of `"$($hash.Error)`"." - } - $hash.IsValid - } - } - } - } - - end { - - } -} diff --git a/Tools/Modules/SDLDevTools/0.1/Get-SDLOpenSourceHeader.ps1 b/Tools/Modules/SDLDevTools/0.2/Get-SDLOpenSourceHeader.ps1 similarity index 84% rename from Tools/Modules/SDLDevTools/0.1/Get-SDLOpenSourceHeader.ps1 rename to Tools/Modules/SDLDevTools/0.2/Get-SDLOpenSourceHeader.ps1 index d040a34..747b61d 100644 --- a/Tools/Modules/SDLDevTools/0.1/Get-SDLOpenSourceHeader.ps1 +++ b/Tools/Modules/SDLDevTools/0.2/Get-SDLOpenSourceHeader.ps1 @@ -35,7 +35,7 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -"@ +"@ $output=$null switch ($Format) { @@ -44,8 +44,16 @@ limitations under the License. } 'CSharp' { $output=@("/*") - $output+=$header -split [System.Environment]::NewLine |ForEach-Object {"* $_"} - $output+=("*/") + $output+=$header -split [System.Environment]::NewLine |ForEach-Object { + if([string]::IsNullOrEmpty($_.ToString())) { +# if([string]::IsNullOrEmpty($_.ToString().Trim())) { + " *" + } + else { + " * $_" + } + } + $output+=(" */") $output+="" } 'PowerShell' { diff --git a/Tools/Modules/SDLDevTools/0.1/Get-SDLOpenSourceHeaderFormat.ps1 b/Tools/Modules/SDLDevTools/0.2/Get-SDLOpenSourceHeaderFormat.ps1 similarity index 100% rename from Tools/Modules/SDLDevTools/0.1/Get-SDLOpenSourceHeaderFormat.ps1 rename to Tools/Modules/SDLDevTools/0.2/Get-SDLOpenSourceHeaderFormat.ps1 diff --git a/Tools/Modules/SDLDevTools/0.1/PSGetModuleInfo.xml b/Tools/Modules/SDLDevTools/0.2/PSGetModuleInfo.xml similarity index 93% rename from Tools/Modules/SDLDevTools/0.1/PSGetModuleInfo.xml rename to Tools/Modules/SDLDevTools/0.2/PSGetModuleInfo.xml index 25a0825259a6699239b7314db10f46c817c4b4a5..df5ce3004da1ee0c48d319d91e494e44173e0518 100644 GIT binary patch delta 209 zcmdlLyd-$T874-f&1abendQwHbQug741uIEkPHE0V+Jb*Qy^^x6t~#?msM4U(-6os z1!D8bg37v+!;~bH4H@*o+VmNWz_dAo0=m}86P5glRA;@}PI(uLI;LBUkln(d$6(H2 V!eF{tUc;1;)d0vfnp~*q2>`EZA$tG- delta 213 zcmZ1yyeoLa874-<&1abendQwGbQuhRP?y1&!GIwI$TDKEVlV}h1`LLq|FWveFk3QM zOy*ZMoE)Jfp=`jQ57wX$R034MV8)<;u4yu>vi0P1N+QIl-OQ@|l|>!X6^6*JV9*1) g&JySvMGaHN$puVe>@h&Q^%x8%f8-RMT%c(J08~#SNB{r; diff --git a/Tools/Modules/SDLDevTools/0.1/SDLDevTools.psm1 b/Tools/Modules/SDLDevTools/0.2/SDLDevTools.psm1 similarity index 98% rename from Tools/Modules/SDLDevTools/0.1/SDLDevTools.psm1 rename to Tools/Modules/SDLDevTools/0.2/SDLDevTools.psm1 index b541d69..f868d04 100644 --- a/Tools/Modules/SDLDevTools/0.1/SDLDevTools.psm1 +++ b/Tools/Modules/SDLDevTools/0.2/SDLDevTools.psm1 @@ -16,7 +16,7 @@ <#PSScriptInfo -.VERSION 0.1 +.VERSION 0.2 #> diff --git a/Tools/Modules/SDLDevTools/0.1/Set-SDLOpenSourceHeader.ps1 b/Tools/Modules/SDLDevTools/0.2/Set-SDLOpenSourceHeader.ps1 similarity index 100% rename from Tools/Modules/SDLDevTools/0.1/Set-SDLOpenSourceHeader.ps1 rename to Tools/Modules/SDLDevTools/0.2/Set-SDLOpenSourceHeader.ps1 diff --git a/Tools/Modules/SDLDevTools/0.2/Test-SDLOpenSourceHeader.ps1 b/Tools/Modules/SDLDevTools/0.2/Test-SDLOpenSourceHeader.ps1 new file mode 100644 index 0000000..07cb540 --- /dev/null +++ b/Tools/Modules/SDLDevTools/0.2/Test-SDLOpenSourceHeader.ps1 @@ -0,0 +1,158 @@ +<# +# Copyright (c) 2014 All Rights Reserved by the SDL Group. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#> + +Function Test-SDLOpenSourceHeader { + param( + [Parameter(Mandatory=$true,ParameterSetName="Folder")] + [string]$FolderPath, + [Parameter(Mandatory=$false,ParameterSetName="Folder")] + [string[]]$ExcludeFolder=$null, + [Parameter(Mandatory=$false,ParameterSetName="Folder")] + [string[]]$ExcludeExtension=$null, + [Parameter(Mandatory=$true,ParameterSetName="File")] + [string]$FilePath, + [Parameter(Mandatory=$false,ParameterSetName="File")] + [Parameter(Mandatory=$false,ParameterSetName="Folder")] + [switch]$PassThru=$false, + [Parameter(Mandatory=$false,ParameterSetName="File")] + [Parameter(Mandatory=$false,ParameterSetName="Folder")] + [switch]$ExpandError=$false + ) + begin { + . $PSScriptRoot\Get-SDLOpenSourceHeader.ps1 + . $PSScriptRoot\Get-SDLOpenSourceHeaderFormat.ps1 + } + process { + switch($PSCmdlet.ParameterSetName) + { + 'Folder' { + Get-ChildItem $FolderPath -Filter "*.*" -Recurse -File | ForEach-Object { + $fullName=$_.FullName + $extension=$_.Extension + if(-not ($fullName)) + { + return + } + if($ExcludeExtension -contains $_.Extension) + { + return + } + $ExcludeFolder | ForEach-Object { + if($fullName -like "*\$_\*") + { + return + } + } + Test-SDLOpenSourceHeader -FilePath ($_.FullName) -PassThru:$PassThru -ExpandError:$ExpandError + } + } + 'File' { + Write-Debug "Calculating format for $FilePath" + $fileFormat=Get-SDLOpenSourceHeaderFormat -FilePath $FilePath + if(-not $fileFormat) + { + Write-Warning "Skipped $FilePath" + break + } + Write-Debug "Testing header for $FilePath" + $header = Get-SDLOpenSourceHeader -Format $fileFormat + $content=Get-Content $FilePath + + $errors=@() + if($content.Count -lt $header.Count) + { + $errors+="Line count less than header" + } + else + { + $numberOfLinesToCompare=$header.Count + #Normally there should be a separator between the header and the first line + if($content[$header.Count-1] -ne $header[$header.Count]) + { + # When it's not the comparison is going to be more linient by not comparing the last "empty line" + $numberOfLinesToCompare=$header.Count-1 + } + $fileHeader=$content|Select-Object -First $numberOfLinesToCompare + $linesWithErrors=@() + for($i=0;$i -lt $numberOfLinesToCompare;$i++) + { + if($header[$i] -ne $content[$i]) + { + if($ExpandError) + { + $errors+="Line $($i+1) actual:$($content[$i])" + $errors+="Line $($i+1) expected:$($header[$i])" + } + else + { + $linesWithErrors+=$i+1 + } + } + } + if((-not $ExpandError) -and $linesWithErrors.Count -gt 0) + { + $errors+="Lines $($linesWithErrors -join ',') don't match" + } + } + $isValid=$errors.Count -eq 0 + if($isValid) + { + $hash=[ordered]@{ + FilePath=$FilePath + Format=$fileFormat + Error=$null + IsValid=$isValid + } + } + else + { + $hash=@() + $errors|ForEach-Object { + $hash+=[ordered]@{ + FilePath=$FilePath + Format=$fileFormat + Error=$_ + IsValid=$isValid + } + } + } + Write-Verbose "Tested header for $FilePath" + if($PassThru) + { + $hash|ForEach-Object { + New-Object -TypeName PSObject -Property $_ + } + } + else + { + if(-not $isValid) + { + $errorLines=@() + $errorLines+="Failed for $FilePath because" + $errorLines+=$errors + $errorMessage=$errorLines-join [System.Environment]::NewLine + Write-Error $errorMessage + } + $hash.IsValid + } + } + } + } + + end { + + } +} \ No newline at end of file From ecb982eebd33773853855651e41626aa8f2bc665 Mon Sep 17 00:00:00 2001 From: Alex Sarafian Date: Mon, 6 Feb 2017 09:06:33 +0100 Subject: [PATCH 3/5] Aws s3 support (#8) * Issue #3 - Added the concept of private functions. - AWS S3 bucker support for Get-ISHPrerequisites and Set-ISHToolAntennaHouseLicense - Some refactoring * #3 Fixed small issues in the Publish-Module.ps1 --- Automation/Publish-Module.ps1 | 13 ++- CHANGELOG.md | 5 ++ .../ISHServer/Get-ISHPrerequisites.ISH12.ps1 | 60 ++++++++++++-- .../ISHServer/Get-ISHPrerequisites.ISH13.ps1 | 60 ++++++++++++-- .../ISHServer/Get-ISHServerFolderPath.ps1 | 7 +- .../ISHServer/Grant-ISHUserLogOnAsService.ps1 | 2 +- Source/Modules/ISHServer/ISHServer.12.psm1 | 13 ++- Source/Modules/ISHServer/ISHServer.13.psm1 | 13 ++- .../Modules/ISHServer/Initialize-ISHIIS.ps1 | 2 +- .../ISHServer/Initialize-ISHLocale.ps1 | 2 +- .../ISHServer/Initialize-ISHMSDTCSettings.ps1 | 2 +- .../Initialize-ISHMSDTCTransactionTimeout.ps1 | 2 +- .../ISHServer/Initialize-ISHRegional.ps1 | 2 +- .../Initialize-ISHRegionalDefault.ps1 | 2 +- .../Modules/ISHServer/Initialize-ISHUser.ps1 | 2 +- .../ISHServer/Install-ISHToolAntennaHouse.ps1 | 2 +- .../ISHServer/Install-ISHToolDotNET.ISH13.ps1 | 2 +- .../ISHServer/Install-ISHToolHtmlHelp.ps1 | 2 +- .../Modules/ISHServer/Install-ISHToolJAVA.ps1 | 2 +- .../ISHServer/Install-ISHToolJavaHelp.ps1 | 2 +- .../ISHServer/Install-ISHToolMSXML4.ps1 | 2 +- .../ISHServer/Install-ISHToolOracleODAC.ps1 | 2 +- .../Install-ISHToolVisualCPP.ISH12.ps1 | 2 +- .../Install-ISHToolVisualCPP.ISH13.ps1 | 2 +- .../Install-ISHVisualBasicRuntime.ps1 | 2 +- .../ISHServer/Install-ISHWindowsFeature.ps1 | 2 +- .../Install-ISHWindowsFeatureIISWinAuth.ps1 | 2 +- .../ISHServer/Private/Get-ISHFTPItem.ps1 | 50 +++++++++++ .../ISHServer/Private/Get-ISHS3Object.ps1 | 83 +++++++++++++++++++ .../{ => Private}/Test-RunningAsElevated.ps1 | 0 .../ISHServer/Set-ISHFirewallHTTPS.ps1 | 2 +- .../ISHServer/Set-ISHFirewallMSDTC.ps1 | 2 +- .../ISHServer/Set-ISHFirewallNETBIOS.ps1 | 2 +- .../ISHServer/Set-ISHFirewallOracle.ps1 | 2 +- .../Modules/ISHServer/Set-ISHFirewallSMTP.ps1 | 2 +- .../ISHServer/Set-ISHFirewallSQLServer.ps1 | 2 +- .../Set-ISHToolAntennaHouseLicense.ps1 | 41 +++++++-- 37 files changed, 335 insertions(+), 62 deletions(-) create mode 100644 Source/Modules/ISHServer/Private/Get-ISHFTPItem.ps1 create mode 100644 Source/Modules/ISHServer/Private/Get-ISHS3Object.ps1 rename Source/Modules/ISHServer/{ => Private}/Test-RunningAsElevated.ps1 (100%) diff --git a/Automation/Publish-Module.ps1 b/Automation/Publish-Module.ps1 index 9293521..60319a0 100644 --- a/Automation/Publish-Module.ps1 +++ b/Automation/Publish-Module.ps1 @@ -20,12 +20,14 @@ param( [string]$NuGetApiKey=$null, [Parameter(Mandatory=$true,ParameterSetName="KC2016+Dev")] [ValidateScript({$_ -ne "PSGallery"})] - [string]$DevRepository, + [string]$DevRepository #, + <# [Parameter(Mandatory=$true,ParameterSetName="KC2016")] [Parameter(Mandatory=$false,ParameterSetName="KC2016+Dev")] [switch]$ISH12=$false, - [Parameter(Mandatory=$true,ParameterSetName="KC2016+Dev")] + [Parameter(Mandatory=$false,ParameterSetName="KC2016+Dev")] [switch]$ISH13=$false + #> ) $moduleNamesToPublish=@() @@ -40,10 +42,7 @@ switch ($PSCmdlet.ParameterSetName) 'KC2016+Dev' { $publishDebug=$true $repository=$DevRepository - if($ISH12) - { - $moduleNamesToPublish+="ISHServer.12" - } + $moduleNamesToPublish+="ISHServer.12" $moduleNamesToPublish+="ISHServer.13" break } @@ -88,7 +87,7 @@ foreach($moduleName in $moduleNamesToPublish) New-Item -Path $modulePath -ItemType Directory|Out-Null Write-Verbose "Temporary working folder $modulePath is ready" - Copy-Item -Path "$PSScriptRoot\..\Source\Modules\ISHServer\*.*" -Destination $modulePath -Recurse + Copy-Item -Path "$PSScriptRoot\..\Source\Modules\ISHServer\*" -Destination $modulePath -Recurse switch ($moduleName) { 'ISHServer.12' { diff --git a/CHANGELOG.md b/CHANGELOG.md index b0cf7d0..4b364f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ **1.1** +- Upgraded the SDLDevTools PowerShell module to version 0.2 +- `Get-ISHPrerequisites` now supports S3 buckets as source. +- `Set-ISHToolAntennaHouseLicense` now supports S3 buckets as source. +- `Test-RunningAsElevated` is now a private function in the module. + **1.0** - Split from [ISHBootstrap](https://github.com/Sarafian/ISHBootstrap). diff --git a/Source/Modules/ISHServer/Get-ISHPrerequisites.ISH12.ps1 b/Source/Modules/ISHServer/Get-ISHPrerequisites.ISH12.ps1 index 2916020..feca609 100644 --- a/Source/Modules/ISHServer/Get-ISHPrerequisites.ISH12.ps1 +++ b/Source/Modules/ISHServer/Get-ISHPrerequisites.ISH12.ps1 @@ -24,6 +24,22 @@ function Get-ISHPrerequisites [pscredential]$Credential, [Parameter(Mandatory=$true,ParameterSetName="From FTP")] [string]$FTPFolder, + [Parameter(Mandatory=$true,ParameterSetName="From AWS S3")] + [string]$BucketName, + [Parameter(Mandatory=$true,ParameterSetName="From AWS S3")] + [string]$FolderKey, + [Parameter(Mandatory=$false,ParameterSetName="From AWS S3")] + [string]$AccessKey, + [Parameter(Mandatory=$false,ParameterSetName="From AWS S3")] + [string]$ProfileName, + [Parameter(Mandatory=$false,ParameterSetName="From AWS S3")] + [string]$ProfileLocation, + [Parameter(Mandatory=$false,ParameterSetName="From AWS S3")] + [string]$Region, + [Parameter(Mandatory=$false,ParameterSetName="From AWS S3")] + [string]$SecretKey, + [Parameter(Mandatory=$false,ParameterSetName="From AWS S3")] + [string]$SessionToken, [Parameter(Mandatory=$true,ParameterSetName="No Download")] [switch]$FileNames ) @@ -32,12 +48,21 @@ function Get-ISHPrerequisites { if($PSCmdlet.ParameterSetName -ne "No Download") { - . $PSScriptRoot\Test-RunningAsElevated.ps1 + . $PSScriptRoot\Private\Test-RunningAsElevated.ps1 Test-RunningAsElevated -StopCallerPSCmdlet $PSCmdlet } . $PSScriptRoot\Get-ISHServerFolderPath.ps1 . $PSScriptRoot\Get-ISHOSInfo.ps1 + + if(-not ($FTPFolder.EndsWith("/"))) + { + $FTPFolder+="/" + } + if(-not ($FolderKey.EndsWith("/"))) + { + $FolderKey+="/" + } } process @@ -68,16 +93,35 @@ function Get-ISHPrerequisites switch ($PSCmdlet.ParameterSetName) { 'From FTP' { - Import-Module PSFTP -ErrorAction Stop + . $PSScriptRoot\Private\Get-ISHFTPItem.ps1 + $localPath=Get-ISHServerFolderPath - Set-FTPConnection -Server $FTPHost -Credentials $Credential -UseBinary -KeepAlive -UsePassive | Out-Null + $paths=@() $filesToDownload | ForEach-Object { - $ftpUrl="$FTPFolder$_" - - Write-Debug "ftpUrl=$ftpUrl" - Get-FTPItem -Path $ftpUrl -LocalPath $localPath -Overwrite | Out-Null - Write-Verbose "Downloaded $ftpUrl" + $paths+="$FTPFolder$_" + } + Get-ISHFTPItem -FTPHost $FTPHost -Credential $Credential -Path $paths -LocalPath $localPath + break + } + 'From AWS S3' { + . $PSScriptRoot\Private\Get-ISHS3Object.ps1 + + $localPath=Get-ISHServerFolderPath + $hash=@{ + BucketName=$BucketName + LocalFolder=$localPath + AccessKey=$AccessKey + ProfileName=$ProfileName + ProfileLocation=$ProfileLocation + Region=$Region + SecretKey=$SecretKey + SessionToken=$SessionToken + } + $keys=@() + $filesToDownload | ForEach-Object { + $keys+="$FolderKey$_" } + Get-ISHS3Object -Key $keys @hash break } 'No Download' { diff --git a/Source/Modules/ISHServer/Get-ISHPrerequisites.ISH13.ps1 b/Source/Modules/ISHServer/Get-ISHPrerequisites.ISH13.ps1 index 4faa09e..c1278da 100644 --- a/Source/Modules/ISHServer/Get-ISHPrerequisites.ISH13.ps1 +++ b/Source/Modules/ISHServer/Get-ISHPrerequisites.ISH13.ps1 @@ -24,6 +24,22 @@ function Get-ISHPrerequisites [pscredential]$Credential, [Parameter(Mandatory=$true,ParameterSetName="From FTP")] [string]$FTPFolder, + [Parameter(Mandatory=$true,ParameterSetName="From AWS S3")] + [string]$BucketName, + [Parameter(Mandatory=$true,ParameterSetName="From AWS S3")] + [string]$FolderKey, + [Parameter(Mandatory=$false,ParameterSetName="From AWS S3")] + [string]$AccessKey, + [Parameter(Mandatory=$false,ParameterSetName="From AWS S3")] + [string]$ProfileName, + [Parameter(Mandatory=$false,ParameterSetName="From AWS S3")] + [string]$ProfileLocation, + [Parameter(Mandatory=$false,ParameterSetName="From AWS S3")] + [string]$Region, + [Parameter(Mandatory=$false,ParameterSetName="From AWS S3")] + [string]$SecretKey, + [Parameter(Mandatory=$false,ParameterSetName="From AWS S3")] + [string]$SessionToken, [Parameter(Mandatory=$true,ParameterSetName="No Download")] [switch]$FileNames ) @@ -32,12 +48,21 @@ function Get-ISHPrerequisites { if($PSCmdlet.ParameterSetName -ne "No Download") { - . $PSScriptRoot\Test-RunningAsElevated.ps1 + . $PSScriptRoot\Private\Test-RunningAsElevated.ps1 Test-RunningAsElevated -StopCallerPSCmdlet $PSCmdlet } . $PSScriptRoot\Get-ISHServerFolderPath.ps1 . $PSScriptRoot\Get-ISHOSInfo.ps1 + + if(-not ($FTPFolder.EndsWith("/"))) + { + $FTPFolder+="/" + } + if(-not ($FolderKey.EndsWith("/"))) + { + $FolderKey+="/" + } } process @@ -77,16 +102,35 @@ function Get-ISHPrerequisites switch ($PSCmdlet.ParameterSetName) { 'From FTP' { - Import-Module PSFTP -ErrorAction Stop + . $PSScriptRoot\Private\Get-ISHFTPItem.ps1 + $localPath=Get-ISHServerFolderPath - Set-FTPConnection -Server $FTPHost -Credentials $Credential -UseBinary -KeepAlive -UsePassive | Out-Null + $paths=@() $filesToDownload | ForEach-Object { - $ftpUrl="$FTPFolder$_" - - Write-Debug "ftpUrl=$ftpUrl" - Get-FTPItem -Path $ftpUrl -LocalPath $localPath -Overwrite | Out-Null - Write-Verbose "Downloaded $ftpUrl" + $paths+="$FTPFolder$_" + } + Get-ISHFTPItem -FTPHost $FTPHost -Credential $Credential -Path $paths -LocalPath $localPath + break + } + 'From AWS S3' { + . $PSScriptRoot\Private\Get-ISHS3Object.ps1 + + $localPath=Get-ISHServerFolderPath + $hash=@{ + BucketName=$BucketName + LocalFolder=$localPath + AccessKey=$AccessKey + ProfileName=$ProfileName + ProfileLocation=$ProfileLocation + Region=$Region + SecretKey=$SecretKey + SessionToken=$SessionToken + } + $keys=@() + $filesToDownload | ForEach-Object { + $keys+="$FolderKey$_" } + Get-ISHS3Object -Key $keys @hash break } 'No Download' { diff --git a/Source/Modules/ISHServer/Get-ISHServerFolderPath.ps1 b/Source/Modules/ISHServer/Get-ISHServerFolderPath.ps1 index 9a70b1b..fd0190d 100644 --- a/Source/Modules/ISHServer/Get-ISHServerFolderPath.ps1 +++ b/Source/Modules/ISHServer/Get-ISHServerFolderPath.ps1 @@ -24,13 +24,18 @@ function Get-ISHServerFolderPath begin { - . $PSScriptRoot\Test-RunningAsElevated.ps1 + . $PSScriptRoot\Private\Test-RunningAsElevated.ps1 Test-RunningAsElevated -StopCallerPSCmdlet $PSCmdlet } process { $moduleName=$($MyInvocation.MyCommand.Module) + if(-not $moduleName) + { + $moduleName="ISHServer.Debug" + Write-Warning "Executed the cmdlet directly. Setting module name to $moduleName" + } $programDataPath=Join-Path $env:ProgramData $moduleName if(-not (Test-Path $programDataPath)) { diff --git a/Source/Modules/ISHServer/Grant-ISHUserLogOnAsService.ps1 b/Source/Modules/ISHServer/Grant-ISHUserLogOnAsService.ps1 index c92c605..3a86d3f 100644 --- a/Source/Modules/ISHServer/Grant-ISHUserLogOnAsService.ps1 +++ b/Source/Modules/ISHServer/Grant-ISHUserLogOnAsService.ps1 @@ -23,7 +23,7 @@ function Grant-ISHUserLogOnAsService{ begin { - . $PSScriptRoot\Test-RunningAsElevated.ps1 + . $PSScriptRoot\Private\Test-RunningAsElevated.ps1 Test-RunningAsElevated -StopCallerPSCmdlet $PSCmdlet } diff --git a/Source/Modules/ISHServer/ISHServer.12.psm1 b/Source/Modules/ISHServer/ISHServer.12.psm1 index 0a9d56e..afc0ac4 100644 --- a/Source/Modules/ISHServer/ISHServer.12.psm1 +++ b/Source/Modules/ISHServer/ISHServer.12.psm1 @@ -14,7 +14,7 @@ # limitations under the License. #> -$importNames=@( +$exportNames=@( #region Helpers "Get-ISHOSInfo" "Get-ISHNETInfo" @@ -68,7 +68,14 @@ $importNames=@( #endregion ) -$importNames | ForEach-Object {. $PSScriptRoot\$_.ps1 } +$privateNames=@( + "Get-ISHFTPItem" + "Get-ISHS3Object" + "Test-RunningAsElevated" +) + +$privateNames | ForEach-Object {. $PSScriptRoot\Private\$_.ps1 } +$exportNames | ForEach-Object {. $PSScriptRoot\$_.ps1 } -$exportedMemberNames=$importNames -replace "\.ISH[0-9]+","" +$exportedMemberNames=$exportNames -replace "\.ISH[0-9]+","" Export-ModuleMember $exportedMemberNames \ No newline at end of file diff --git a/Source/Modules/ISHServer/ISHServer.13.psm1 b/Source/Modules/ISHServer/ISHServer.13.psm1 index c7ac3c8..f89de7a 100644 --- a/Source/Modules/ISHServer/ISHServer.13.psm1 +++ b/Source/Modules/ISHServer/ISHServer.13.psm1 @@ -14,7 +14,7 @@ # limitations under the License. #> -$importNames=@( +$exportNames=@( #region Helpers "Get-ISHOSInfo" "Get-ISHNETInfo" @@ -65,7 +65,14 @@ $importNames=@( #endregion ) -$importNames | ForEach-Object {. $PSScriptRoot\$_.ps1 } +$privateNames=@( + "Get-ISHFTPItem" + "Get-ISHS3Object" + "Test-RunningAsElevated" +) + +$privateNames | ForEach-Object {. $PSScriptRoot\Private\$_.ps1 } +$exportNames | ForEach-Object {. $PSScriptRoot\$_.ps1 } -$exportedMemberNames=$importNames -replace "\.ISH[0-9]+","" +$exportedMemberNames=$exportNames -replace "\.ISH[0-9]+","" Export-ModuleMember $exportedMemberNames \ No newline at end of file diff --git a/Source/Modules/ISHServer/Initialize-ISHIIS.ps1 b/Source/Modules/ISHServer/Initialize-ISHIIS.ps1 index 5911af3..102b28c 100644 --- a/Source/Modules/ISHServer/Initialize-ISHIIS.ps1 +++ b/Source/Modules/ISHServer/Initialize-ISHIIS.ps1 @@ -21,7 +21,7 @@ function Initialize-ISHIIS begin { - . $PSScriptRoot\Test-RunningAsElevated.ps1 + . $PSScriptRoot\Private\Test-RunningAsElevated.ps1 Test-RunningAsElevated -StopCallerPSCmdlet $PSCmdlet } diff --git a/Source/Modules/ISHServer/Initialize-ISHLocale.ps1 b/Source/Modules/ISHServer/Initialize-ISHLocale.ps1 index d3d4e1e..d927f6e 100644 --- a/Source/Modules/ISHServer/Initialize-ISHLocale.ps1 +++ b/Source/Modules/ISHServer/Initialize-ISHLocale.ps1 @@ -21,7 +21,7 @@ function Initialize-ISHLocale begin { - . $PSScriptRoot\Test-RunningAsElevated.ps1 + . $PSScriptRoot\Private\Test-RunningAsElevated.ps1 Test-RunningAsElevated -StopCallerPSCmdlet $PSCmdlet } diff --git a/Source/Modules/ISHServer/Initialize-ISHMSDTCSettings.ps1 b/Source/Modules/ISHServer/Initialize-ISHMSDTCSettings.ps1 index 2295f21..81ac20d 100644 --- a/Source/Modules/ISHServer/Initialize-ISHMSDTCSettings.ps1 +++ b/Source/Modules/ISHServer/Initialize-ISHMSDTCSettings.ps1 @@ -21,7 +21,7 @@ function Initialize-ISHMSDTCSettings begin { - . $PSScriptRoot\Test-RunningAsElevated.ps1 + . $PSScriptRoot\Private\Test-RunningAsElevated.ps1 Test-RunningAsElevated -StopCallerPSCmdlet $PSCmdlet } diff --git a/Source/Modules/ISHServer/Initialize-ISHMSDTCTransactionTimeout.ps1 b/Source/Modules/ISHServer/Initialize-ISHMSDTCTransactionTimeout.ps1 index b2a23c1..b681475 100644 --- a/Source/Modules/ISHServer/Initialize-ISHMSDTCTransactionTimeout.ps1 +++ b/Source/Modules/ISHServer/Initialize-ISHMSDTCTransactionTimeout.ps1 @@ -21,7 +21,7 @@ function Initialize-ISHMSDTCTransactionTimeout begin { - . $PSScriptRoot\Test-RunningAsElevated.ps1 + . $PSScriptRoot\Private\Test-RunningAsElevated.ps1 Test-RunningAsElevated -StopCallerPSCmdlet $PSCmdlet } diff --git a/Source/Modules/ISHServer/Initialize-ISHRegional.ps1 b/Source/Modules/ISHServer/Initialize-ISHRegional.ps1 index 1e6f571..1d6ee30 100644 --- a/Source/Modules/ISHServer/Initialize-ISHRegional.ps1 +++ b/Source/Modules/ISHServer/Initialize-ISHRegional.ps1 @@ -21,7 +21,7 @@ function Initialize-ISHRegional begin { - . $PSScriptRoot\Test-RunningAsElevated.ps1 + . $PSScriptRoot\Private\Test-RunningAsElevated.ps1 Test-RunningAsElevated -StopCallerPSCmdlet $PSCmdlet } diff --git a/Source/Modules/ISHServer/Initialize-ISHRegionalDefault.ps1 b/Source/Modules/ISHServer/Initialize-ISHRegionalDefault.ps1 index 99cb4d4..689e479 100644 --- a/Source/Modules/ISHServer/Initialize-ISHRegionalDefault.ps1 +++ b/Source/Modules/ISHServer/Initialize-ISHRegionalDefault.ps1 @@ -21,7 +21,7 @@ function Initialize-ISHRegionalDefault begin { - . $PSScriptRoot\Test-RunningAsElevated.ps1 + . $PSScriptRoot\Private\Test-RunningAsElevated.ps1 Test-RunningAsElevated -StopCallerPSCmdlet $PSCmdlet } diff --git a/Source/Modules/ISHServer/Initialize-ISHUser.ps1 b/Source/Modules/ISHServer/Initialize-ISHUser.ps1 index f72cb53..517fdec 100644 --- a/Source/Modules/ISHServer/Initialize-ISHUser.ps1 +++ b/Source/Modules/ISHServer/Initialize-ISHUser.ps1 @@ -24,7 +24,7 @@ function Initialize-ISHUser begin { - . $PSScriptRoot\Test-RunningAsElevated.ps1 + . $PSScriptRoot\Private\Test-RunningAsElevated.ps1 Test-RunningAsElevated -StopCallerPSCmdlet $PSCmdlet } diff --git a/Source/Modules/ISHServer/Install-ISHToolAntennaHouse.ps1 b/Source/Modules/ISHServer/Install-ISHToolAntennaHouse.ps1 index 5cc728d..f17671c 100644 --- a/Source/Modules/ISHServer/Install-ISHToolAntennaHouse.ps1 +++ b/Source/Modules/ISHServer/Install-ISHToolAntennaHouse.ps1 @@ -21,7 +21,7 @@ function Install-ISHToolAntennaHouse begin { - . $PSScriptRoot\Test-RunningAsElevated.ps1 + . $PSScriptRoot\Private\Test-RunningAsElevated.ps1 Test-RunningAsElevated -StopCallerPSCmdlet $PSCmdlet . $PSScriptRoot\Get-ISHServerFolderPath.ps1 diff --git a/Source/Modules/ISHServer/Install-ISHToolDotNET.ISH13.ps1 b/Source/Modules/ISHServer/Install-ISHToolDotNET.ISH13.ps1 index 17edd16..cb53061 100644 --- a/Source/Modules/ISHServer/Install-ISHToolDotNET.ISH13.ps1 +++ b/Source/Modules/ISHServer/Install-ISHToolDotNET.ISH13.ps1 @@ -21,7 +21,7 @@ function Install-ISHToolDotNET begin { - . $PSScriptRoot\Test-RunningAsElevated.ps1 + . $PSScriptRoot\Private\Test-RunningAsElevated.ps1 Test-RunningAsElevated -StopCallerPSCmdlet $PSCmdlet . $PSScriptRoot\Get-ISHServerFolderPath.ps1 diff --git a/Source/Modules/ISHServer/Install-ISHToolHtmlHelp.ps1 b/Source/Modules/ISHServer/Install-ISHToolHtmlHelp.ps1 index 8367d35..20b5fbd 100644 --- a/Source/Modules/ISHServer/Install-ISHToolHtmlHelp.ps1 +++ b/Source/Modules/ISHServer/Install-ISHToolHtmlHelp.ps1 @@ -21,7 +21,7 @@ function Install-ISHToolHtmlHelp begin { - . $PSScriptRoot\Test-RunningAsElevated.ps1 + . $PSScriptRoot\Private\Test-RunningAsElevated.ps1 Test-RunningAsElevated -StopCallerPSCmdlet $PSCmdlet . $PSScriptRoot\Get-ISHServerFolderPath.ps1 diff --git a/Source/Modules/ISHServer/Install-ISHToolJAVA.ps1 b/Source/Modules/ISHServer/Install-ISHToolJAVA.ps1 index 26fbb84..6c27fea 100644 --- a/Source/Modules/ISHServer/Install-ISHToolJAVA.ps1 +++ b/Source/Modules/ISHServer/Install-ISHToolJAVA.ps1 @@ -21,7 +21,7 @@ function Install-ISHToolJAVA begin { - . $PSScriptRoot\Test-RunningAsElevated.ps1 + . $PSScriptRoot\Private\Test-RunningAsElevated.ps1 Test-RunningAsElevated -StopCallerPSCmdlet $PSCmdlet . $PSScriptRoot\Get-ISHServerFolderPath.ps1 diff --git a/Source/Modules/ISHServer/Install-ISHToolJavaHelp.ps1 b/Source/Modules/ISHServer/Install-ISHToolJavaHelp.ps1 index 425206e..f7e465c 100644 --- a/Source/Modules/ISHServer/Install-ISHToolJavaHelp.ps1 +++ b/Source/Modules/ISHServer/Install-ISHToolJavaHelp.ps1 @@ -23,7 +23,7 @@ function Install-ISHToolJavaHelp begin { - . $PSScriptRoot\Test-RunningAsElevated.ps1 + . $PSScriptRoot\Private\Test-RunningAsElevated.ps1 Test-RunningAsElevated -StopCallerPSCmdlet $PSCmdlet } diff --git a/Source/Modules/ISHServer/Install-ISHToolMSXML4.ps1 b/Source/Modules/ISHServer/Install-ISHToolMSXML4.ps1 index f07d414..4290d3d 100644 --- a/Source/Modules/ISHServer/Install-ISHToolMSXML4.ps1 +++ b/Source/Modules/ISHServer/Install-ISHToolMSXML4.ps1 @@ -21,7 +21,7 @@ function Install-ISHToolMSXML4 begin { - . $PSScriptRoot\Test-RunningAsElevated.ps1 + . $PSScriptRoot\Private\Test-RunningAsElevated.ps1 Test-RunningAsElevated -StopCallerPSCmdlet $PSCmdlet } diff --git a/Source/Modules/ISHServer/Install-ISHToolOracleODAC.ps1 b/Source/Modules/ISHServer/Install-ISHToolOracleODAC.ps1 index 7c42d4a..129c2ed 100644 --- a/Source/Modules/ISHServer/Install-ISHToolOracleODAC.ps1 +++ b/Source/Modules/ISHServer/Install-ISHToolOracleODAC.ps1 @@ -21,7 +21,7 @@ function Install-ISHToolOracleODAC begin { - . $PSScriptRoot\Test-RunningAsElevated.ps1 + . $PSScriptRoot\Private\Test-RunningAsElevated.ps1 Test-RunningAsElevated -StopCallerPSCmdlet $PSCmdlet . $PSScriptRoot\Get-ISHServerFolderPath.ps1 diff --git a/Source/Modules/ISHServer/Install-ISHToolVisualCPP.ISH12.ps1 b/Source/Modules/ISHServer/Install-ISHToolVisualCPP.ISH12.ps1 index 17c6e23..c0ba67f 100644 --- a/Source/Modules/ISHServer/Install-ISHToolVisualCPP.ISH12.ps1 +++ b/Source/Modules/ISHServer/Install-ISHToolVisualCPP.ISH12.ps1 @@ -21,7 +21,7 @@ function Install-ISHToolVisualCPP begin { - . $PSScriptRoot\Test-RunningAsElevated.ps1 + . $PSScriptRoot\Private\Test-RunningAsElevated.ps1 Test-RunningAsElevated -StopCallerPSCmdlet $PSCmdlet . $PSScriptRoot\Get-ISHServerFolderPath.ps1 diff --git a/Source/Modules/ISHServer/Install-ISHToolVisualCPP.ISH13.ps1 b/Source/Modules/ISHServer/Install-ISHToolVisualCPP.ISH13.ps1 index 2d2e267..351256b 100644 --- a/Source/Modules/ISHServer/Install-ISHToolVisualCPP.ISH13.ps1 +++ b/Source/Modules/ISHServer/Install-ISHToolVisualCPP.ISH13.ps1 @@ -21,7 +21,7 @@ function Install-ISHToolVisualCPP begin { - . $PSScriptRoot\Test-RunningAsElevated.ps1 + . $PSScriptRoot\Private\Test-RunningAsElevated.ps1 Test-RunningAsElevated -StopCallerPSCmdlet $PSCmdlet . $PSScriptRoot\Get-ISHServerFolderPath.ps1 diff --git a/Source/Modules/ISHServer/Install-ISHVisualBasicRuntime.ps1 b/Source/Modules/ISHServer/Install-ISHVisualBasicRuntime.ps1 index 90df4b0..cc96378 100644 --- a/Source/Modules/ISHServer/Install-ISHVisualBasicRuntime.ps1 +++ b/Source/Modules/ISHServer/Install-ISHVisualBasicRuntime.ps1 @@ -21,7 +21,7 @@ function Install-ISHVisualBasicRuntime begin { - . $PSScriptRoot\Test-RunningAsElevated.ps1 + . $PSScriptRoot\Private\Test-RunningAsElevated.ps1 Test-RunningAsElevated -StopCallerPSCmdlet $PSCmdlet . $PSScriptRoot\Get-ISHServerFolderPath.ps1 diff --git a/Source/Modules/ISHServer/Install-ISHWindowsFeature.ps1 b/Source/Modules/ISHServer/Install-ISHWindowsFeature.ps1 index 1a786cc..2f5928d 100644 --- a/Source/Modules/ISHServer/Install-ISHWindowsFeature.ps1 +++ b/Source/Modules/ISHServer/Install-ISHWindowsFeature.ps1 @@ -21,7 +21,7 @@ function Install-ISHWindowsFeature begin { - . $PSScriptRoot\Test-RunningAsElevated.ps1 + . $PSScriptRoot\Private\Test-RunningAsElevated.ps1 Test-RunningAsElevated -StopCallerPSCmdlet $PSCmdlet . $PSScriptRoot\Get-ISHOSInfo.ps1 diff --git a/Source/Modules/ISHServer/Install-ISHWindowsFeatureIISWinAuth.ps1 b/Source/Modules/ISHServer/Install-ISHWindowsFeatureIISWinAuth.ps1 index 16efbbb..9fee362 100644 --- a/Source/Modules/ISHServer/Install-ISHWindowsFeatureIISWinAuth.ps1 +++ b/Source/Modules/ISHServer/Install-ISHWindowsFeatureIISWinAuth.ps1 @@ -21,7 +21,7 @@ function Install-ISHWindowsFeatureIISWinAuth begin { - . $PSScriptRoot\Test-RunningAsElevated.ps1 + . $PSScriptRoot\Private\Test-RunningAsElevated.ps1 Test-RunningAsElevated -StopCallerPSCmdlet $PSCmdlet } diff --git a/Source/Modules/ISHServer/Private/Get-ISHFTPItem.ps1 b/Source/Modules/ISHServer/Private/Get-ISHFTPItem.ps1 new file mode 100644 index 0000000..4152726 --- /dev/null +++ b/Source/Modules/ISHServer/Private/Get-ISHFTPItem.ps1 @@ -0,0 +1,50 @@ +<# +# Copyright (c) 2014 All Rights Reserved by the SDL Group. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#> + +function Get-ISHFTPItem +{ + [CmdletBinding()] + param( + [Parameter(Mandatory=$true)] + [string]$FTPHost, + [Parameter(Mandatory=$true)] + [pscredential]$Credential, + [Parameter(Mandatory=$true)] + [string[]]$Path, + [Parameter(Mandatory=$true)] + [string]$LocalPath + ) + + begin + { + Import-Module PSFTP -ErrorAction Stop + Set-FTPConnection -Server $FTPHost -Credentials $Credential -UseBinary -KeepAlive -UsePassive | Out-Null + } + + process + { + $Path | ForEach-Object { + Write-Debug "Path=$_" + Get-FTPItem -Path $_ -LocalPath $LocalPath -Overwrite | Out-Null + Write-Verbose "Downloaded $_ to $LocalPath" + } + } + + end + { + + } +} diff --git a/Source/Modules/ISHServer/Private/Get-ISHS3Object.ps1 b/Source/Modules/ISHServer/Private/Get-ISHS3Object.ps1 new file mode 100644 index 0000000..c533158 --- /dev/null +++ b/Source/Modules/ISHServer/Private/Get-ISHS3Object.ps1 @@ -0,0 +1,83 @@ +<# +# Copyright (c) 2014 All Rights Reserved by the SDL Group. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#> + +function Get-ISHS3Object +{ + [CmdletBinding()] + param( + [Parameter(Mandatory=$true)] + [string]$BucketName, + [Parameter(Mandatory=$true)] + [string[]]$Key, + [Parameter(Mandatory=$true)] + [string]$LocalFolder, + [Parameter(Mandatory=$false)] + [string]$AccessKey, + [Parameter(Mandatory=$false)] + [string]$ProfileName, + [Parameter(Mandatory=$false)] + [string]$ProfileLocation, + [Parameter(Mandatory=$false)] + [string]$Region, + [Parameter(Mandatory=$false)] + [string]$SecretKey, + [Parameter(Mandatory=$false)] + [string]$SessionToken + ) + + begin + { + Import-Module AWSPowerShell -ErrorAction Stop + $hash=@{ + BucketName=$BucketName + } + # Filling in the base splat hash to be used with Copy-S3Object + if($AccessKey){ + $hash.AccessKey=$AccessKey + } + if($ProfileName){ + $hash.ProfileName=$ProfileName + } + if($ProfileLocation){ + $hash.ProfileLocation=$ProfileLocation + } + if($Region){ + $hash.Region=$Region + } + if($SecretKey){ + $hash.SecretKey=$SecretKey + } + if($SessionToken){ + $hash.SessionToken=$SessionToken + } + } + + process + { + $Key | ForEach-Object { + $localFile=Join-Path $LocalFolder ($_.Substring($_.LastIndexOf('/')+1)) + Write-Debug "key=$_" + Write-Debug "localFile=$localFile" + Copy-S3Object -Key $_ -LocalFile $localFile @hash |Out-Null + Write-Verbose "Downloaded $_ to $localFile" + } + } + + end + { + + } +} diff --git a/Source/Modules/ISHServer/Test-RunningAsElevated.ps1 b/Source/Modules/ISHServer/Private/Test-RunningAsElevated.ps1 similarity index 100% rename from Source/Modules/ISHServer/Test-RunningAsElevated.ps1 rename to Source/Modules/ISHServer/Private/Test-RunningAsElevated.ps1 diff --git a/Source/Modules/ISHServer/Set-ISHFirewallHTTPS.ps1 b/Source/Modules/ISHServer/Set-ISHFirewallHTTPS.ps1 index cbebfa4..ba28a7e 100644 --- a/Source/Modules/ISHServer/Set-ISHFirewallHTTPS.ps1 +++ b/Source/Modules/ISHServer/Set-ISHFirewallHTTPS.ps1 @@ -21,7 +21,7 @@ function Set-ISHFirewallHTTPS begin { - . $PSScriptRoot\Test-RunningAsElevated.ps1 + . $PSScriptRoot\Private\Test-RunningAsElevated.ps1 Test-RunningAsElevated -StopCallerPSCmdlet $PSCmdlet } diff --git a/Source/Modules/ISHServer/Set-ISHFirewallMSDTC.ps1 b/Source/Modules/ISHServer/Set-ISHFirewallMSDTC.ps1 index 7ea0c29..da5983e 100644 --- a/Source/Modules/ISHServer/Set-ISHFirewallMSDTC.ps1 +++ b/Source/Modules/ISHServer/Set-ISHFirewallMSDTC.ps1 @@ -21,7 +21,7 @@ function Set-ISHFirewallMSDTC begin { - . $PSScriptRoot\Test-RunningAsElevated.ps1 + . $PSScriptRoot\Private\Test-RunningAsElevated.ps1 Test-RunningAsElevated -StopCallerPSCmdlet $PSCmdlet } diff --git a/Source/Modules/ISHServer/Set-ISHFirewallNETBIOS.ps1 b/Source/Modules/ISHServer/Set-ISHFirewallNETBIOS.ps1 index 7ba717c..a6d71c3 100644 --- a/Source/Modules/ISHServer/Set-ISHFirewallNETBIOS.ps1 +++ b/Source/Modules/ISHServer/Set-ISHFirewallNETBIOS.ps1 @@ -21,7 +21,7 @@ function Set-ISHFirewallNETBIOS begin { - . $PSScriptRoot\Test-RunningAsElevated.ps1 + . $PSScriptRoot\Private\Test-RunningAsElevated.ps1 Test-RunningAsElevated -StopCallerPSCmdlet $PSCmdlet } diff --git a/Source/Modules/ISHServer/Set-ISHFirewallOracle.ps1 b/Source/Modules/ISHServer/Set-ISHFirewallOracle.ps1 index 0ba1bd0..7e40a4f 100644 --- a/Source/Modules/ISHServer/Set-ISHFirewallOracle.ps1 +++ b/Source/Modules/ISHServer/Set-ISHFirewallOracle.ps1 @@ -21,7 +21,7 @@ function Set-ISHFirewallOracle begin { - . $PSScriptRoot\Test-RunningAsElevated.ps1 + . $PSScriptRoot\Private\Test-RunningAsElevated.ps1 Test-RunningAsElevated -StopCallerPSCmdlet $PSCmdlet } diff --git a/Source/Modules/ISHServer/Set-ISHFirewallSMTP.ps1 b/Source/Modules/ISHServer/Set-ISHFirewallSMTP.ps1 index 4654898..5c82af5 100644 --- a/Source/Modules/ISHServer/Set-ISHFirewallSMTP.ps1 +++ b/Source/Modules/ISHServer/Set-ISHFirewallSMTP.ps1 @@ -21,7 +21,7 @@ function Set-ISHFirewallSMTP begin { - . $PSScriptRoot\Test-RunningAsElevated.ps1 + . $PSScriptRoot\Private\Test-RunningAsElevated.ps1 Test-RunningAsElevated -StopCallerPSCmdlet $PSCmdlet } diff --git a/Source/Modules/ISHServer/Set-ISHFirewallSQLServer.ps1 b/Source/Modules/ISHServer/Set-ISHFirewallSQLServer.ps1 index c3af4f0..88de3eb 100644 --- a/Source/Modules/ISHServer/Set-ISHFirewallSQLServer.ps1 +++ b/Source/Modules/ISHServer/Set-ISHFirewallSQLServer.ps1 @@ -21,7 +21,7 @@ function Set-ISHFirewallSQLServer begin { - . $PSScriptRoot\Test-RunningAsElevated.ps1 + . $PSScriptRoot\Private\Test-RunningAsElevated.ps1 Test-RunningAsElevated -StopCallerPSCmdlet $PSCmdlet } diff --git a/Source/Modules/ISHServer/Set-ISHToolAntennaHouseLicense.ps1 b/Source/Modules/ISHServer/Set-ISHToolAntennaHouseLicense.ps1 index dc8ffa5..596e274 100644 --- a/Source/Modules/ISHServer/Set-ISHToolAntennaHouseLicense.ps1 +++ b/Source/Modules/ISHServer/Set-ISHToolAntennaHouseLicense.ps1 @@ -25,13 +25,30 @@ function Set-ISHToolAntennaHouseLicense [Parameter(Mandatory=$true,ParameterSetName="From FTP")] [ValidatePattern(".*AHFormatter\.lic")] [string]$FTPPath, + [Parameter(Mandatory=$true,ParameterSetName="From AWS S3")] + [string]$BucketName, + [Parameter(Mandatory=$true,ParameterSetName="From AWS S3")] + [ValidatePattern(".*AHFormatter\.lic")] + [string]$Key, + [Parameter(Mandatory=$false,ParameterSetName="From AWS S3")] + [string]$AccessKey, + [Parameter(Mandatory=$false,ParameterSetName="From AWS S3")] + [string]$ProfileName, + [Parameter(Mandatory=$false,ParameterSetName="From AWS S3")] + [string]$ProfileLocation, + [Parameter(Mandatory=$false,ParameterSetName="From AWS S3")] + [string]$Region, + [Parameter(Mandatory=$false,ParameterSetName="From AWS S3")] + [string]$SecretKey, + [Parameter(Mandatory=$false,ParameterSetName="From AWS S3")] + [string]$SessionToken, [Parameter(Mandatory=$true,ParameterSetName="Content")] $Content ) begin { - . $PSScriptRoot\Test-RunningAsElevated.ps1 + . $PSScriptRoot\Private\Test-RunningAsElevated.ps1 Test-RunningAsElevated -StopCallerPSCmdlet $PSCmdlet . $PSScriptRoot\Get-ISHServerFolderPath.ps1 @@ -60,11 +77,23 @@ function Set-ISHToolAntennaHouseLicense switch ($PSCmdlet.ParameterSetName) { 'From FTP' { - Import-Module PSFTP -ErrorAction Stop - Set-FTPConnection -Server $FTPHost -Credentials $Credential -UseBinary -KeepAlive -UsePassive | Out-Null - Write-Debug "FTPPath=$FTPPath" - Get-FTPItem -Path $FTPPath -LocalPath $antennaHouseFolderPath -Overwrite | Out-Null - Write-Verbose "Downloaded $ftpUrl" + Get-ISHFTPItem -FTPHost $FTPHost -Credential $Credential -Path $FTPPath -LocalPath $antennaHouseFolderPath + break + } + 'From AWS S3' { + . $PSScriptRoot\Private\Get-ISHS3Object.ps1 + $hash=@{ + BucketName=$BucketName + LocalFolder=$antennaHouseFolderPath + AccessKey=$AccessKey + ProfileName=$ProfileName + ProfileLocation=$ProfileLocation + Region=$Region + SecretKey=$SecretKey + SessionToken=$SessionToken + } + + Get-ISHS3Object -Key $Key @hash break } 'Content' { From bdf71e0f66ae889c280ed2b86312c55e2666f503 Mon Sep 17 00:00:00 2001 From: Alex Sarafian Date: Mon, 6 Feb 2017 09:23:22 +0100 Subject: [PATCH 4/5] Copy expand cd (#9) * Issue #3 - Added the concept of private functions. - AWS S3 bucker support for Get-ISHPrerequisites and Set-ISHToolAntennaHouseLicense - Some refactoring * #3 Fixed small issues in the Publish-Module.ps1 * #7 - Added `Get-ISHCD` cmdlet - Added `Expand-ISHCD` cmdlet * #7 Small fix * #7 - Optimized Publish automation - Fixed bugs * #7 - Improved the Get-ISHCD ListAvailable functionality - Enhanced the README.MD * Upgrade SDLDevTools to version 0.3 --- Automation/Pester/Test-SDLHeaders.Tests.ps1 | 33 ++-- Automation/Publish-Module.ps1 | 76 ++++---- CHANGELOG.md | 4 + README.md | 24 ++- Source/Modules/ISHServer/Expand-ISHCD.ps1 | 103 ++++++++++ Source/Modules/ISHServer/Get-ISHCD.ps1 | 176 ++++++++++++++++++ .../ISHServer/Get-ISHPrerequisites.ISH12.ps1 | 4 +- .../ISHServer/Get-ISHPrerequisites.ISH13.ps1 | 4 +- Source/Modules/ISHServer/ISHServer.12.psm1 | 5 + Source/Modules/ISHServer/ISHServer.13.psm1 | 5 + .../ISHServer/Private/Get-ISHFTPItem.ps1 | 4 +- .../ISHServer/Private/Get-ISHS3Object.ps1 | 2 +- .../Set-ISHToolAntennaHouseLicense.ps1 | 4 +- .../{0.2 => 0.3}/Get-SDLOpenSourceHeader.ps1 | 0 .../Get-SDLOpenSourceHeaderFormat.ps1 | 0 .../{0.2 => 0.3}/PSGetModuleInfo.xml | Bin 10660 -> 10660 bytes .../SDLDevTools/{0.2 => 0.3}/SDLDevTools.psm1 | 2 +- .../{0.2 => 0.3}/Set-SDLOpenSourceHeader.ps1 | 0 .../{0.2 => 0.3}/Test-SDLOpenSourceHeader.ps1 | 9 +- 19 files changed, 384 insertions(+), 71 deletions(-) create mode 100644 Source/Modules/ISHServer/Expand-ISHCD.ps1 create mode 100644 Source/Modules/ISHServer/Get-ISHCD.ps1 rename Tools/Modules/SDLDevTools/{0.2 => 0.3}/Get-SDLOpenSourceHeader.ps1 (100%) rename Tools/Modules/SDLDevTools/{0.2 => 0.3}/Get-SDLOpenSourceHeaderFormat.ps1 (100%) rename Tools/Modules/SDLDevTools/{0.2 => 0.3}/PSGetModuleInfo.xml (95%) rename Tools/Modules/SDLDevTools/{0.2 => 0.3}/SDLDevTools.psm1 (98%) rename Tools/Modules/SDLDevTools/{0.2 => 0.3}/Set-SDLOpenSourceHeader.ps1 (100%) rename Tools/Modules/SDLDevTools/{0.2 => 0.3}/Test-SDLOpenSourceHeader.ps1 (96%) diff --git a/Automation/Pester/Test-SDLHeaders.Tests.ps1 b/Automation/Pester/Test-SDLHeaders.Tests.ps1 index cbf0179..a51128d 100644 --- a/Automation/Pester/Test-SDLHeaders.Tests.ps1 +++ b/Automation/Pester/Test-SDLHeaders.Tests.ps1 @@ -14,23 +14,28 @@ # limitations under the License. #> -$sourcePath=Resolve-Path "$PSScriptRoot\..\.." +$repositoryPath=Resolve-Path "$PSScriptRoot\..\.." +$modulePath=Resolve-Path "$repositoryPath\Tools\Modules" -Import-Module "$sourcePath\Tools\Modules\SDLDevTools" -Force +Import-Module "$modulePath\SDLDevTools" -Force -# Must convert to array of hash to drive the It -Testcases parameter -$filesToValidate=@() -Get-ChildItem -Path $sourcePath -Recurse -File -Exclude ".git" |Select-Object Name,FullName|ForEach-Object { - $hash=@{ - Name=$_.Name - FullName=$_.FullName - } - $filesToValidate+=$hash -} +$reportToValidate=@() +Test-SDLOpenSourceHeader -ExcludeFolder ".git" -FolderPath $repositoryPath -PassThru | ForEach-Object { + $hash=@{} + $hash.FilePath=$_.FilePath + $hash.Format=$_.Format + $hash.Error=$_.Error + $hash.IsValid=$_.IsValid + $reportToValidate+=$hash +} Describe "Verify open source headers" { - It "Test-SDLOpenSourceHeader " -TestCases $filesToValidate { - param ($Name,$FullName) - Test-SDLOpenSourceHeader -FilePath $FullName + It "Test-SDLOpenSourceHeader " -TestCases $reportToValidate { + param ($FilePath,$Format,$Error,$IsValid) + if(-not $IsValid) + { + Write-Warning "$Error in $FilePath" + } + $IsValid | Should BeExactly $true } } diff --git a/Automation/Publish-Module.ps1 b/Automation/Publish-Module.ps1 index 60319a0..cdb2929 100644 --- a/Automation/Publish-Module.ps1 +++ b/Automation/Publish-Module.ps1 @@ -29,7 +29,6 @@ param( [switch]$ISH13=$false #> ) - $moduleNamesToPublish=@() switch ($PSCmdlet.ParameterSetName) { @@ -157,50 +156,49 @@ foreach($moduleName in $moduleNamesToPublish) } #endregion - if($shouldTryPublish) - { - #region manifest - Write-Debug "Generating manifest" + #region manifest + Write-Debug "Generating manifest" - Import-Module $psm1Path -Force - $exportedNames=Get-Command -Module $moduleName | Select-Object -ExcludeProperty Name - - $psm1Name=$moduleName+".psm1" - $psd1Path=Join-Path $modulePath "$moduleName.psd1" - $guid="c1e7cbac-9e47-4906-8281-5f16471d7ccd" - $hash=@{ - "Author"="SDL plc" - "CompanyName" = "SDL plc" - "Copyright"="SDL plc. All rights reserved." - "RootModule"=$psm1Name - "Description"="Prerequisite automation module for SDL Knowledge Center Content Manager 12.0.* (LiveContent Architect, Trisoft InfoShare)" - "ModuleVersion"=$sourceVersion - "Path"=$psd1Path - "LicenseUri"='https://github.com/Sarafian/ISHServer/blob/master/LICENSE' - "ProjectUri"= 'https://github.com/Sarafian/ISHServer/' - "ReleaseNotes"= 'https://github.com/Sarafian/ISHServer/blob/master/CHANGELOG.md' - "CmdletsToExport" = $exportedNames - "FunctionsToExport" = $exportedNames + Import-Module $psm1Path -Force + $exportedNames=Get-Command -Module $moduleName | Select-Object -ExcludeProperty Name + $psm1Name=$moduleName+".psm1" + $psd1Path=Join-Path $modulePath "$moduleName.psd1" + $guid="c1e7cbac-9e47-4906-8281-5f16471d7ccd" + $hash=@{ + "Author"="SDL plc" + "CompanyName" = "SDL plc" + "Copyright"="SDL plc. All rights reserved." + "RootModule"=$psm1Name + "Description"="Prerequisite automation module for SDL Knowledge Center Content Manager 12.0.* (LiveContent Architect, Trisoft InfoShare)" + "ModuleVersion"=$sourceVersion + "Path"=$psd1Path + "LicenseUri"='https://github.com/Sarafian/ISHServer/blob/master/LICENSE' + "ProjectUri"= 'https://github.com/Sarafian/ISHServer/' + "ReleaseNotes"= 'https://github.com/Sarafian/ISHServer/blob/master/CHANGELOG.md' + "CmdletsToExport" = $exportedNames + "FunctionsToExport" = $exportedNames + } + switch ($moduleName) + { + 'ISHServer.12' { + $hash.Description="Prerequisite automation module for SDL Knowledge Center 2016 Content Manager 12.0.* (LiveContent Architect, Trisoft InfoShare)" + $hash.Guid="469894fc-530e-47dd-9158-ed5148815712" + break } - switch ($moduleName) - { - 'ISHServer.12' { - $hash.Description="Prerequisite automation module for SDL Knowledge Center 2016 Content Manager 12.0.* (LiveContent Architect, Trisoft InfoShare)" - $hash.Guid="469894fc-530e-47dd-9158-ed5148815712" - break - } - 'ISHServer.13' { - $hash.Description="Prerequisite automation module for SDL Knowledge Center Content Manager 13.0.* (LiveContent Architect, Trisoft InfoShare)" - $hash.Guid="c73125ea-0914-4a1c-958b-05eccd6c2c29" - break - } + 'ISHServer.13' { + $hash.Description="Prerequisite automation module for SDL Knowledge Center Content Manager 13.0.* (LiveContent Architect, Trisoft InfoShare)" + $hash.Guid="c73125ea-0914-4a1c-958b-05eccd6c2c29" + break } + } - New-ModuleManifest @hash + New-ModuleManifest @hash - Write-Verbose "Generated manifest" - #endregion + Write-Verbose "Generated manifest" + #endregion + if($shouldTryPublish) + { #region publish Write-Debug "Publishing $moduleName" Write-Progress -Activity $progressActivity -Status "Publishing..." diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b364f9..7157c21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ - `Get-ISHPrerequisites` now supports S3 buckets as source. - `Set-ISHToolAntennaHouseLicense` now supports S3 buckets as source. - `Test-RunningAsElevated` is now a private function in the module. +- New `Get-ISHCD` cmdlet: + - Downloads a CD from FTP or AWS S3 bucket. + - Returns the available CDs +- New `Expand-ISHCD` cmdlet expands a CD into `C:\ISHCD`. **1.0** diff --git a/README.md b/README.md index 463f3b3..76741fc 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,15 @@ A PowerShell module to help automate installation of prerequisites for **Knowled The module requires elevated privileges for most of its cmdlets. +## Prerequisite and CD sources + +The module can retrieve files from the following type of sources: + +- FTP. +- Amazon Web Services S3 bucket. + +For each different type of credentials are required. + ## Preparation To test if the operating system is compatible execute first `Test-ISHServerCompliance`. @@ -38,10 +47,7 @@ NETFramework2013_4.5_MicrosoftVisualC++Redistributable_(vcredist_x64).exe ``` If you want to manually make the files available to the module then copy them to the location provided by `Get-ISHServerFolderPath`. -As an alternative, the `Get-ISHPrerequisites` cmdlet offers the option to download the files from a known location and will take care of everything. -Current options are: - -- FTP. Just provide the ftp hostname, a relative folder path containing the above files and the credentials. e.g. `Get-ISHPrerequisites -Credential $Credential -FTPFolder $folderPath -FTPHost $host`. +As an alternative, the `Get-ISHPrerequisites` cmdlet offers the option to download the files will take care of everything. ## Installing and configuring @@ -50,6 +56,16 @@ The module is structured in manner that represents the steps described in the pr Understanding the prerequisites and how to configure them will be helpful but it is not a requirement. An example of how to use the sequence the installation and configuration is available in [ISHBootstrap](https://github.com/Sarafian/ISHBootstrap). +## CD Management + +ISHServer offers two cmdlets to download and expand the ISHCD. **Notice that it will not install a CD!** +- `Get-ISHCD` can download a CD or show the ones already downloaded and expanded. +- `Expand-ISHCD` will expand the CD. + +The target path is always `C:\ISHCD\X.0.Z` where `X` is the major version and `Y` the revision. +- For `12.0.1` it's `C:\ISHCD\12.0.1` +- For `12.0.3` it's `C:\ISHCD\12.0.3` + ## Maintenance For installation and maintenance reasons, the module offers a couple of general purpose cmdlets: diff --git a/Source/Modules/ISHServer/Expand-ISHCD.ps1 b/Source/Modules/ISHServer/Expand-ISHCD.ps1 new file mode 100644 index 0000000..6922778 --- /dev/null +++ b/Source/Modules/ISHServer/Expand-ISHCD.ps1 @@ -0,0 +1,103 @@ +<# +# Copyright (c) 2014 All Rights Reserved by the SDL Group. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#> + +function Expand-ISHCD +{ + [CmdletBinding()] + param( + [Parameter(Mandatory=$true)] + [ValidatePattern(".+\.[0-9]+\.0\.[0-9]+\.[0-9]+.*\.exe")] + [string]$FileName, + [Parameter(Mandatory=$false)] + [switch]$Force=$false + ) + + begin + { + . $PSScriptRoot\Private\Test-RunningAsElevated.ps1 + Test-RunningAsElevated -StopCallerPSCmdlet $PSCmdlet + + . $PSScriptRoot\Get-ISHServerFolderPath.ps1 + . $PSScriptRoot\Get-ISHCD.ps1 + } + + process + { + $ishCDPath="C:\IshCD" + + $localPath=Get-ISHServerFolderPath + $cdPath=Join-Path $localPath $FileName + if(-not (Test-Path $cdPath)) + { + Write-Error "$FileName doesn't exist." + return + } + $regEx=".+\.(?[0-9]+)\.0\.(?[0-9]+)\.(?[0-9]+).+\.exe" + if($FileName -notmatch $regEx) + { + Write-Error "$FileName has unknown format." + return + } + + $major=[int]$Matches["Major"] + $build=[int]$Matches["Build"] + $revision=[int]$Matches["Revision"] + + $ishVersion="$($major).0.$($revision)" + Write-Debug "ishVersion=$ishVersion" + $expandPath="$ishCDPath\$ishVersion" + Write-Debug "expandPath=$expandPath" + + if($major -lt 12) + { + Write-Error "Only CD's with major version 12 or higher are supported." + } + if(Get-ISHCD -ListAvailable |Where-Object -Property Name -EQ $FileName|Where-Object -Property IsExpanded -EQ $true) + { + if(-not $Force) + { + Write-Warning "$Filename is already expanded. Skipping ..." + return + } + } + + if($major -eq "12") + { + #CD is compressed with WinRar + $arguments=@("-d$expandPath","-s") + } + else + { + #CD is compressed with 7Zip + $arguments=@( + "-y" + "-gm2" + "-InstallPath=`"$($expandPath.Replace('\','\\'))`"" + ) + } + Write-Debug "arguments=$($arguments -join " ")" + + Write-Debug "Unzipping $cdPath in $expandPath" + Start-Process $cdPath -ArgumentList $arguments -Wait + Write-Verbose "Unzipped $cdPath in $expandPath" + + } + + end + { + + } +} diff --git a/Source/Modules/ISHServer/Get-ISHCD.ps1 b/Source/Modules/ISHServer/Get-ISHCD.ps1 new file mode 100644 index 0000000..601b861 --- /dev/null +++ b/Source/Modules/ISHServer/Get-ISHCD.ps1 @@ -0,0 +1,176 @@ +<# +# Copyright (c) 2014 All Rights Reserved by the SDL Group. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#> + +function Get-ISHCD +{ + [CmdletBinding()] + param( + [Parameter(Mandatory=$true,ParameterSetName="From FTP")] + [string]$FTPHost, + [Parameter(Mandatory=$true,ParameterSetName="From FTP")] + [pscredential]$Credential, + [Parameter(Mandatory=$true,ParameterSetName="From FTP")] + [ValidatePattern(".+\.[0-9]+\.0\.[0-9]+\.[0-9]+.*\.exe")] + [string]$FTPPath, + [Parameter(Mandatory=$true,ParameterSetName="From AWS S3")] + [string]$BucketName, + [Parameter(Mandatory=$true,ParameterSetName="From AWS S3")] + [ValidatePattern(".+\.[0-9]+\.0\.[0-9]+\.[0-9]+.*\.exe")] + [string]$Key, + [Parameter(Mandatory=$false,ParameterSetName="From AWS S3")] + [string]$AccessKey, + [Parameter(Mandatory=$false,ParameterSetName="From AWS S3")] + [string]$ProfileName, + [Parameter(Mandatory=$false,ParameterSetName="From AWS S3")] + [string]$ProfileLocation, + [Parameter(Mandatory=$false,ParameterSetName="From AWS S3")] + [string]$Region, + [Parameter(Mandatory=$false,ParameterSetName="From AWS S3")] + [string]$SecretKey, + [Parameter(Mandatory=$false,ParameterSetName="From AWS S3")] + [string]$SessionToken, + [Parameter(Mandatory=$false,ParameterSetName="From FTP")] + [Parameter(Mandatory=$false,ParameterSetName="From AWS S3")] + [switch]$Expand=$false, + [Parameter(Mandatory=$true,ParameterSetName="List")] + [switch]$ListAvailable + ) + + begin + { + if($PSCmdlet.ParameterSetName -ne "List") + { + . $PSScriptRoot\Private\Test-RunningAsElevated.ps1 + Test-RunningAsElevated -StopCallerPSCmdlet $PSCmdlet + } + + . $PSScriptRoot\Get-ISHServerFolderPath.ps1 + } + + process + { + $localPath=Get-ISHServerFolderPath + switch ($PSCmdlet.ParameterSetName) + { + 'From FTP' { + . $PSScriptRoot\Private\Get-ISHFTPItem.ps1 + + $newItem=Get-ISHFTPItem -FTPHost $FTPHost -Credential $Credential -Path $FTPPath -LocalPath $localPath + if($Expand) + { + . $PSScriptRoot\Expand-ISHCD.ps1 + Expand-ISHCD -FileName $newItem.Name + } + break + } + 'From AWS S3' { + . $PSScriptRoot\Private\Get-ISHS3Object.ps1 + $hash=@{ + BucketName=$BucketName + LocalFolder=$localPath + AccessKey=$AccessKey + ProfileName=$ProfileName + ProfileLocation=$ProfileLocation + Region=$Region + SecretKey=$SecretKey + SessionToken=$SessionToken + } + + $newItem=Get-ISHS3Object -Key $Key @hash + if($Expand) + { + . $PSScriptRoot\Expand-ISHCD.ps1 + Expand-ISHCD -FileName $newItem.Name + } + break + } + 'List' { + function RemoveSDLSegments([string]$path) + { + return $path.Replace(".Test","").Replace(".Prod","") + } + $regEx=".+\.(?[0-9]+)\.0\.(?[0-9]+)\.(?[0-9]+)(\.Test)*(\.Prod)*.+\.exe" + $availableItems=@() + $ishCDPath="C:\IshCD" + Get-ChildItem -Path $localPath -File |Where-Object -Property Name -Match $regEx|ForEach-Object { + $hash=[ordered]@{ + Name=$_.Name + Major=[int]$Matches["Major"] + Minor=0 + Build=[int]$Matches["Build"] + Revision=[int]$Matches["Revision"] + IsExpanded=$false + ExpandedPath=$null + } + + $ishVersion="$($hash.Major).0.$($hash.Revision)" + Write-Debug "ishVersion=$ishVersion" + $expandPath="$ishCDPath\$ishVersion" + Write-Debug "expandPath=$expandPath" + $testPath=Join-Path -Path $expandPath -ChildPath ($_.Name.Replace(".exe","")) + $testPath=RemoveSDLSegments($testPath) + $hash.IsExpanded=Test-Path $testPath -PathType Container + if($hash.IsExpanded) + { + $hash.ExpandedPath=$testPath + } + $availableItems+=New-Object -TypeName PSObject -Property $hash + } + if(Test-Path -Path $ishCDPath -PathType Container) + { + if($PSVersionTable.PSVersion.Major -ge 5) + { + $childItems=Get-ChildItem -Path $ishCDPath -Recurse -Directory -Depth 1 + } + else + { + $childItems=Get-ChildItem -Path $ishCDPath -Recurse -Directory + } + } + else + { + $childItems=$null + } + $childItems |Where-Object -Property Name -Match ($regEx.Replace("\.exe","")) | ForEach-Object { + $directoryName=$_.Name + if($availableItems |Where-Object { + ((RemoveSDLSegments($_.Name).Replace(".exe","")) -eq $directoryName) + }) + { + return + } + $hash=[ordered]@{ + Name=$_.Name + Major=[int]$Matches["Major"] + Minor=0 + Build=[int]$Matches["Build"] + Revision=[int]$Matches["Revision"] + IsExpanded=$true + ExpandedPath=$_.FullName + } + $availableItems+=New-Object -TypeName PSObject -Property $hash + } + $availableItems + break + } + } + } + + end + { + + } +} diff --git a/Source/Modules/ISHServer/Get-ISHPrerequisites.ISH12.ps1 b/Source/Modules/ISHServer/Get-ISHPrerequisites.ISH12.ps1 index feca609..34df612 100644 --- a/Source/Modules/ISHServer/Get-ISHPrerequisites.ISH12.ps1 +++ b/Source/Modules/ISHServer/Get-ISHPrerequisites.ISH12.ps1 @@ -100,7 +100,7 @@ function Get-ISHPrerequisites $filesToDownload | ForEach-Object { $paths+="$FTPFolder$_" } - Get-ISHFTPItem -FTPHost $FTPHost -Credential $Credential -Path $paths -LocalPath $localPath + Get-ISHFTPItem -FTPHost $FTPHost -Credential $Credential -Path $paths -LocalPath $localPath | Out-Null break } 'From AWS S3' { @@ -121,7 +121,7 @@ function Get-ISHPrerequisites $filesToDownload | ForEach-Object { $keys+="$FolderKey$_" } - Get-ISHS3Object -Key $keys @hash + Get-ISHS3Object -Key $keys @hash | Out-Null break } 'No Download' { diff --git a/Source/Modules/ISHServer/Get-ISHPrerequisites.ISH13.ps1 b/Source/Modules/ISHServer/Get-ISHPrerequisites.ISH13.ps1 index c1278da..aca9d14 100644 --- a/Source/Modules/ISHServer/Get-ISHPrerequisites.ISH13.ps1 +++ b/Source/Modules/ISHServer/Get-ISHPrerequisites.ISH13.ps1 @@ -109,7 +109,7 @@ function Get-ISHPrerequisites $filesToDownload | ForEach-Object { $paths+="$FTPFolder$_" } - Get-ISHFTPItem -FTPHost $FTPHost -Credential $Credential -Path $paths -LocalPath $localPath + Get-ISHFTPItem -FTPHost $FTPHost -Credential $Credential -Path $paths -LocalPath $localPath | Out-Null break } 'From AWS S3' { @@ -130,7 +130,7 @@ function Get-ISHPrerequisites $filesToDownload | ForEach-Object { $keys+="$FolderKey$_" } - Get-ISHS3Object -Key $keys @hash + Get-ISHS3Object -Key $keys @hash | Out-Null break } 'No Download' { diff --git a/Source/Modules/ISHServer/ISHServer.12.psm1 b/Source/Modules/ISHServer/ISHServer.12.psm1 index afc0ac4..13eccc7 100644 --- a/Source/Modules/ISHServer/ISHServer.12.psm1 +++ b/Source/Modules/ISHServer/ISHServer.12.psm1 @@ -66,6 +66,11 @@ $exportNames=@( #region License "Set-ISHToolAntennaHouseLicense" #endregion + + #region CD + "Expand-ISHCD" + "Get-ISHCD" + #endregion ) $privateNames=@( diff --git a/Source/Modules/ISHServer/ISHServer.13.psm1 b/Source/Modules/ISHServer/ISHServer.13.psm1 index f89de7a..5c5b69a 100644 --- a/Source/Modules/ISHServer/ISHServer.13.psm1 +++ b/Source/Modules/ISHServer/ISHServer.13.psm1 @@ -63,6 +63,11 @@ $exportNames=@( #region License "Set-ISHToolAntennaHouseLicense" #endregion + + #region CD + "Expand-ISHCD" + "Get-ISHCD" + #endregion ) $privateNames=@( diff --git a/Source/Modules/ISHServer/Private/Get-ISHFTPItem.ps1 b/Source/Modules/ISHServer/Private/Get-ISHFTPItem.ps1 index 4152726..6f4e202 100644 --- a/Source/Modules/ISHServer/Private/Get-ISHFTPItem.ps1 +++ b/Source/Modules/ISHServer/Private/Get-ISHFTPItem.ps1 @@ -38,8 +38,10 @@ function Get-ISHFTPItem { $Path | ForEach-Object { Write-Debug "Path=$_" - Get-FTPItem -Path $_ -LocalPath $LocalPath -Overwrite | Out-Null + Get-FTPItem -Path $_ -LocalPath $LocalPath -Overwrite Write-Verbose "Downloaded $_ to $LocalPath" + $filePath=Join-Path $LocalPath ($_.Substring($_.LastIndexOf('/')+1)) + Get-Item -Path $filePath } } diff --git a/Source/Modules/ISHServer/Private/Get-ISHS3Object.ps1 b/Source/Modules/ISHServer/Private/Get-ISHS3Object.ps1 index c533158..24c70c9 100644 --- a/Source/Modules/ISHServer/Private/Get-ISHS3Object.ps1 +++ b/Source/Modules/ISHServer/Private/Get-ISHS3Object.ps1 @@ -71,7 +71,7 @@ function Get-ISHS3Object $localFile=Join-Path $LocalFolder ($_.Substring($_.LastIndexOf('/')+1)) Write-Debug "key=$_" Write-Debug "localFile=$localFile" - Copy-S3Object -Key $_ -LocalFile $localFile @hash |Out-Null + Copy-S3Object -Key $_ -LocalFile $localFile @hash Write-Verbose "Downloaded $_ to $localFile" } } diff --git a/Source/Modules/ISHServer/Set-ISHToolAntennaHouseLicense.ps1 b/Source/Modules/ISHServer/Set-ISHToolAntennaHouseLicense.ps1 index 596e274..035b467 100644 --- a/Source/Modules/ISHServer/Set-ISHToolAntennaHouseLicense.ps1 +++ b/Source/Modules/ISHServer/Set-ISHToolAntennaHouseLicense.ps1 @@ -77,7 +77,7 @@ function Set-ISHToolAntennaHouseLicense switch ($PSCmdlet.ParameterSetName) { 'From FTP' { - Get-ISHFTPItem -FTPHost $FTPHost -Credential $Credential -Path $FTPPath -LocalPath $antennaHouseFolderPath + Get-ISHFTPItem -FTPHost $FTPHost -Credential $Credential -Path $FTPPath -LocalPath $antennaHouseFolderPath | Out-Null break } 'From AWS S3' { @@ -93,7 +93,7 @@ function Set-ISHToolAntennaHouseLicense SessionToken=$SessionToken } - Get-ISHS3Object -Key $Key @hash + Get-ISHS3Object -Key $Key @hash | Out-Null break } 'Content' { diff --git a/Tools/Modules/SDLDevTools/0.2/Get-SDLOpenSourceHeader.ps1 b/Tools/Modules/SDLDevTools/0.3/Get-SDLOpenSourceHeader.ps1 similarity index 100% rename from Tools/Modules/SDLDevTools/0.2/Get-SDLOpenSourceHeader.ps1 rename to Tools/Modules/SDLDevTools/0.3/Get-SDLOpenSourceHeader.ps1 diff --git a/Tools/Modules/SDLDevTools/0.2/Get-SDLOpenSourceHeaderFormat.ps1 b/Tools/Modules/SDLDevTools/0.3/Get-SDLOpenSourceHeaderFormat.ps1 similarity index 100% rename from Tools/Modules/SDLDevTools/0.2/Get-SDLOpenSourceHeaderFormat.ps1 rename to Tools/Modules/SDLDevTools/0.3/Get-SDLOpenSourceHeaderFormat.ps1 diff --git a/Tools/Modules/SDLDevTools/0.2/PSGetModuleInfo.xml b/Tools/Modules/SDLDevTools/0.3/PSGetModuleInfo.xml similarity index 95% rename from Tools/Modules/SDLDevTools/0.2/PSGetModuleInfo.xml rename to Tools/Modules/SDLDevTools/0.3/PSGetModuleInfo.xml index df5ce3004da1ee0c48d319d91e494e44173e0518..b62b3aab54f5e1d9d283c3dd007260a132668929 100644 GIT binary patch delta 193 zcmZ1yyd-$T874;K&1ad!nI(-FbQug7j2J=~3>i!qte~V3gX!kKthzFcCX*K`=}wMN z5>o{!(g!Qm2eJ%+3e6c5&^1kFRkogdPDzM3)tgzBf3qkeyTBOP1q^x&#z0GqH!Esb QGBO%Z{>Ujhxj@qd086ML3jhEB delta 193 zcmZ1yyd-$T874-f&1ad!nI#PwbQz2p3>iXz*qFhJ!4ybaF&HpdZ2rrtE5m3$d7+Z- z;eWo26F}z2Gh-o S8kUTVMw35sicT)jGywol?I9Nc diff --git a/Tools/Modules/SDLDevTools/0.2/SDLDevTools.psm1 b/Tools/Modules/SDLDevTools/0.3/SDLDevTools.psm1 similarity index 98% rename from Tools/Modules/SDLDevTools/0.2/SDLDevTools.psm1 rename to Tools/Modules/SDLDevTools/0.3/SDLDevTools.psm1 index f868d04..a6a8126 100644 --- a/Tools/Modules/SDLDevTools/0.2/SDLDevTools.psm1 +++ b/Tools/Modules/SDLDevTools/0.3/SDLDevTools.psm1 @@ -16,7 +16,7 @@ <#PSScriptInfo -.VERSION 0.2 +.VERSION 0.3 #> diff --git a/Tools/Modules/SDLDevTools/0.2/Set-SDLOpenSourceHeader.ps1 b/Tools/Modules/SDLDevTools/0.3/Set-SDLOpenSourceHeader.ps1 similarity index 100% rename from Tools/Modules/SDLDevTools/0.2/Set-SDLOpenSourceHeader.ps1 rename to Tools/Modules/SDLDevTools/0.3/Set-SDLOpenSourceHeader.ps1 diff --git a/Tools/Modules/SDLDevTools/0.2/Test-SDLOpenSourceHeader.ps1 b/Tools/Modules/SDLDevTools/0.3/Test-SDLOpenSourceHeader.ps1 similarity index 96% rename from Tools/Modules/SDLDevTools/0.2/Test-SDLOpenSourceHeader.ps1 rename to Tools/Modules/SDLDevTools/0.3/Test-SDLOpenSourceHeader.ps1 index 07cb540..b467b16 100644 --- a/Tools/Modules/SDLDevTools/0.2/Test-SDLOpenSourceHeader.ps1 +++ b/Tools/Modules/SDLDevTools/0.3/Test-SDLOpenSourceHeader.ps1 @@ -50,11 +50,10 @@ Function Test-SDLOpenSourceHeader { { return } - $ExcludeFolder | ForEach-Object { - if($fullName -like "*\$_\*") - { - return - } + if($ExcludeFolder | Where-Object { + $fullName -like "*\$_\*" + }){ + return } Test-SDLOpenSourceHeader -FilePath ($_.FullName) -PassThru:$PassThru -ExpandError:$ExpandError } From e085ed08feb4dcdab105a52766011807d22b706b Mon Sep 17 00:00:00 2001 From: Alex Sarafian Date: Mon, 6 Feb 2017 13:25:36 +0100 Subject: [PATCH 5/5] Auto changelog to manifest (#10) * Publish scripts picks up automatically the release notes from the changelog.md * no message --- Automation/Publish-Module.ps1 | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/Automation/Publish-Module.ps1 b/Automation/Publish-Module.ps1 index cdb2929..1949e8e 100644 --- a/Automation/Publish-Module.ps1 +++ b/Automation/Publish-Module.ps1 @@ -29,6 +29,8 @@ param( [switch]$ISH13=$false #> ) +Set-StrictMode -Version latest + $moduleNamesToPublish=@() switch ($PSCmdlet.ParameterSetName) { @@ -52,14 +54,14 @@ if((& "$PSScriptRoot\Test-All.ps1") -ne 0) Write-Warning "Tests failed. Stopping..." return } - +$changeLogPath="$PSScriptRoot\..\CHANGELOG.md" +$changeLog=Get-Content -Path $changeLogPath if($publishDebug) { $revision=0 $date=(Get-Date).ToUniversalTime() $build=[string](1200 * ($date.Year -2015)+$date.Month*100+$date.Day) $build+=$date.ToString("HHmm") - $sourceVersion+=".$build.$revision" } @@ -164,6 +166,31 @@ foreach($moduleName in $moduleNamesToPublish) $psm1Name=$moduleName+".psm1" $psd1Path=Join-Path $modulePath "$moduleName.psd1" $guid="c1e7cbac-9e47-4906-8281-5f16471d7ccd" + + $possition = "None" + $releaseNotes=foreach ($line in $changelogContent) { + if ($line.StartsWith("**")){ + if($possition -eq "None"){ + $possition="This Version" + } + else + { + $possition="Next Version" + } + continue + } + If($possition -eq "This Version"){ + if($line) + { + $line + } + } + } + $releaseNotes+=@( + "" + "https://github.com/Sarafian/ISHServer/blob/master/CHANGELOG.md" + ) + $hash=@{ "Author"="SDL plc" "CompanyName" = "SDL plc" @@ -174,7 +201,7 @@ foreach($moduleName in $moduleNamesToPublish) "Path"=$psd1Path "LicenseUri"='https://github.com/Sarafian/ISHServer/blob/master/LICENSE' "ProjectUri"= 'https://github.com/Sarafian/ISHServer/' - "ReleaseNotes"= 'https://github.com/Sarafian/ISHServer/blob/master/CHANGELOG.md' + "ReleaseNotes"= $releaseNotes -join [System.Environment]::NewLine "CmdletsToExport" = $exportedNames "FunctionsToExport" = $exportedNames }