Skip to content

Commit

Permalink
Merge pull request #30 from Sarafian/develop
Browse files Browse the repository at this point in the history
Develop to Master for version 1.5
  • Loading branch information
Sarafian authored Apr 19, 2017
2 parents 2ae17fa + 71deaaa commit ef7edb4
Show file tree
Hide file tree
Showing 17 changed files with 457 additions and 51 deletions.
19 changes: 18 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
**1.5**

Issues:
- GH-27: Improve management of OSUser.
- GH-12: Avoid downloading when the file is already available.

In detail:
- `Initialize-ISHUser` is **deleted** and split into `Set-ISHUserLocal`, `Set-ISHUserAdministrator`, `Initialize-ISHUserLocalProfile` and `Initialize-ISHRegistry`.
- `Set-ISHUserLocal` adds the osuser when necessary to the local user registry. When the user exists, it will update the password.
- `Set-ISHUserAdministrator` sets the osuser as the local administrator.
- `Initialize-ISHUserLocalProfile` forces the osuser to fully initialize, including the user profile directory.
- `Initialize-ISHRegistry` disables registry unload.
- `Get-ISHNormalizedCredential` normalizes the credentials so they are good with all cmdlets. This is required before using any cmdlet that accepts credentials for the osuser.
- `Get-ISHPrerequisites` will skip downloading files that are already downloaded. Use the `-Force` parameter to force the download regardless.

**1.4**

-GH-23: New dependency to [PoshPrivilege](https://www.powershellgallery.com/packages/PoshPrivilege/) for `Grant-ISHUserLogOnAsService`.
Issues:
- GH-23: New dependency to [PoshPrivilege](https://www.powershellgallery.com/packages/PoshPrivilege/) for `Grant-ISHUserLogOnAsService`.

**1.3**

Issues:

- GH-20: Install-ISHWindowsFeature failes withing a Docker container

**1.2**
Expand Down
13 changes: 9 additions & 4 deletions Source/Modules/ISHServer/Get-ISHCD.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ function Get-ISHCD
[Parameter(Mandatory=$false,ParameterSetName="From Azure FileStorage")]
[Parameter(Mandatory=$false,ParameterSetName="From Azure BlobStorage")]
[switch]$Expand=$false,
[Parameter(Mandatory=$false,ParameterSetName="From FTP")]
[Parameter(Mandatory=$false,ParameterSetName="From AWS S3")]
[Parameter(Mandatory=$false,ParameterSetName="From Azure FileStorage")]
[Parameter(Mandatory=$false,ParameterSetName="From Azure BlobStorage")]
[switch]$Force=$false,
[Parameter(Mandatory=$true,ParameterSetName="List")]
[switch]$ListAvailable
)
Expand All @@ -86,7 +91,7 @@ function Get-ISHCD
'From FTP' {
. $PSScriptRoot\Private\Get-ISHFTPItem.ps1

$newItem=Get-ISHFTPItem -FTPHost $FTPHost -Credential $Credential -Path $FTPPath -LocalPath $localPath
$newItem=Get-ISHFTPItem -FTPHost $FTPHost -Credential $Credential -Path $FTPPath -LocalPath $localPath -Force:$Force
if($Expand)
{
. $PSScriptRoot\Expand-ISHCD.ps1
Expand All @@ -107,7 +112,7 @@ function Get-ISHCD
SessionToken=$SessionToken
}

$newItem=Get-ISHS3Object -Key $Key @hash
$newItem=Get-ISHS3Object -Key $Key @hash -Force:$Force
if($Expand)
{
. $PSScriptRoot\Expand-ISHCD.ps1
Expand All @@ -124,7 +129,7 @@ function Get-ISHCD
StorageAccountKey=$StorageAccountKey
}

$newItem=Get-ISHAzureFileObject -Path $Path @hash
$newItem=Get-ISHAzureFileObject -Path $Path @hash -Force:$Force
if($Expand)
{
. $PSScriptRoot\Expand-ISHCD.ps1
Expand All @@ -141,7 +146,7 @@ function Get-ISHCD
StorageAccountKey=$StorageAccountKey
}

$newItem=Get-ISHAzureBlobObject -BlobName $BlobName @hash
$newItem=Get-ISHAzureBlobObject -BlobName $BlobName @hash -Force:$Force
if($Expand)
{
. $PSScriptRoot\Expand-ISHCD.ps1
Expand Down
52 changes: 52 additions & 0 deletions Source/Modules/ISHServer/Get-ISHNormalizedCredential.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<#
# 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-ISHNormalizedCredential
{
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)]
[pscredential]$Credentials
)

begin
{
}

process
{

if($Credentials.UserName.StartsWith(".\"))
{
Write-Warning "Credentials normalization.Replaced .\ with $env:COMPUTERNAME"
New-Object System.Management.Automation.PSCredential($Credentials.UserName.Replace(".",$env:COMPUTERNAME),$Credentials.Password)
}
elseif($Credentials.UserName.indexOf("\") -lt 0)
{
Write-Warning "Credentials normalization.Prefixed with $env:COMPUTERNAME"
New-Object System.Management.Automation.PSCredential("$env:COMPUTERNAME\$($Credentials.UserName)",$Credentials.Password)
}
else
{
$Credentials
}
}

end
{

}
}
21 changes: 14 additions & 7 deletions Source/Modules/ISHServer/Get-ISHPrerequisites.ISH12.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ function Get-ISHPrerequisites
[Parameter(Mandatory=$true,ParameterSetName="From Azure FileStorage")]
[Parameter(Mandatory=$true,ParameterSetName="From Azure BlobStorage")]
[string]$StorageAccountKey,
[Parameter(Mandatory=$false,ParameterSetName="From FTP")]
[Parameter(Mandatory=$false,ParameterSetName="From AWS S3")]
[Parameter(Mandatory=$false,ParameterSetName="From Azure FileStorage")]
[Parameter(Mandatory=$false,ParameterSetName="From Azure BlobStorage")]
[switch]$Force=$false,
[Parameter(Mandatory=$true,ParameterSetName="No Download")]
[switch]$FileNames
)
Expand Down Expand Up @@ -107,23 +112,26 @@ function Get-ISHPrerequisites
$filesToDownload+="vbrun60sp6.exe"
}

if($PSCmdlet.ParameterSetName -ne "No Download")
{
$localPath=Get-ISHServerFolderPath
}

switch ($PSCmdlet.ParameterSetName)
{
'From FTP' {
. $PSScriptRoot\Private\Get-ISHFTPItem.ps1

$localPath=Get-ISHServerFolderPath
$paths=@()
$filesToDownload | ForEach-Object {
$paths+="$FTPFolder$_"
}
Get-ISHFTPItem -FTPHost $FTPHost -Credential $Credential -Path $paths -LocalPath $localPath | Out-Null
Get-ISHFTPItem -FTPHost $FTPHost -Credential $Credential -Path $paths -LocalPath $localPath -Force:$Force | Out-Null
break
}
'From AWS S3' {
. $PSScriptRoot\Private\Get-ISHS3Object.ps1

$localPath=Get-ISHServerFolderPath
$hash=@{
BucketName=$BucketName
LocalFolder=$localPath
Expand All @@ -138,7 +146,7 @@ function Get-ISHPrerequisites
$filesToDownload | ForEach-Object {
$keys+="$FolderKey$_"
}
Get-ISHS3Object -Key $keys @hash | Out-Null
Get-ISHS3Object -Key $keys @hash -Force:$Force | Out-Null
break
}
'From Azure FileStorage' {
Expand All @@ -155,13 +163,12 @@ function Get-ISHPrerequisites
$filesToDownload | ForEach-Object {
$paths+="$FolderPath$_"
}
Get-ISHAzureFileObject -Path $paths @hash | Out-Null
Get-ISHAzureFileObject -Path $paths @hash -Force:$Force | Out-Null
break
}
'From Azure BlobStorage' {
. $PSScriptRoot\Private\Get-ISHAzureBlobObject.ps1

$localPath=Get-ISHServerFolderPath
$hash=@{
ContainerName=$ContainerName
LocalFolder=$localPath
Expand All @@ -172,7 +179,7 @@ function Get-ISHPrerequisites
$filesToDownload | ForEach-Object {
$blobs+="$FolderPath$_"
}
Get-ISHAzureBlobObject -BlobName $blobs @hash | Out-Null
Get-ISHAzureBlobObject -BlobName $blobs @hash -Force:$Force | Out-Null
break
}
'No Download' {
Expand Down
21 changes: 14 additions & 7 deletions Source/Modules/ISHServer/Get-ISHPrerequisites.ISH13.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ function Get-ISHPrerequisites
[Parameter(Mandatory=$true,ParameterSetName="From Azure FileStorage")]
[Parameter(Mandatory=$true,ParameterSetName="From Azure BlobStorage")]
[string]$StorageAccountKey,
[Parameter(Mandatory=$false,ParameterSetName="From FTP")]
[Parameter(Mandatory=$false,ParameterSetName="From AWS S3")]
[Parameter(Mandatory=$false,ParameterSetName="From Azure FileStorage")]
[Parameter(Mandatory=$false,ParameterSetName="From Azure BlobStorage")]
[switch]$Force=$false,
[Parameter(Mandatory=$true,ParameterSetName="No Download")]
[switch]$FileNames
)
Expand Down Expand Up @@ -116,23 +121,26 @@ function Get-ISHPrerequisites
$filesToDownload+="vbrun60sp6.exe"
}

if($PSCmdlet.ParameterSetName -ne "No Download")
{
$localPath=Get-ISHServerFolderPath
}

switch ($PSCmdlet.ParameterSetName)
{
'From FTP' {
. $PSScriptRoot\Private\Get-ISHFTPItem.ps1

$localPath=Get-ISHServerFolderPath
$paths=@()
$filesToDownload | ForEach-Object {
$paths+="$FTPFolder$_"
}
Get-ISHFTPItem -FTPHost $FTPHost -Credential $Credential -Path $paths -LocalPath $localPath | Out-Null
Get-ISHFTPItem -FTPHost $FTPHost -Credential $Credential -Path $paths -LocalPath $localPath -Force:$Force | Out-Null
break
}
'From AWS S3' {
. $PSScriptRoot\Private\Get-ISHS3Object.ps1

$localPath=Get-ISHServerFolderPath
$hash=@{
BucketName=$BucketName
LocalFolder=$localPath
Expand All @@ -147,13 +155,12 @@ function Get-ISHPrerequisites
$filesToDownload | ForEach-Object {
$keys+="$FolderKey$_"
}
Get-ISHS3Object -Key $keys @hash | Out-Null
Get-ISHS3Object -Key $keys @hash -Force:$Force | Out-Null
break
}
'From Azure FileStorage' {
. $PSScriptRoot\Private\Get-ISHAzureFileObject.ps1

$localPath=Get-ISHServerFolderPath
$hash=@{
ShareName=$ShareName
LocalFolder=$localPath
Expand All @@ -164,7 +171,7 @@ function Get-ISHPrerequisites
$filesToDownload | ForEach-Object {
$paths+="$FolderPath$_"
}
Get-ISHAzureFileObject -Path $paths @hash | Out-Null
Get-ISHAzureFileObject -Path $paths @hash -Force:$Force | Out-Null
break
}
'From Azure BlobStorage' {
Expand All @@ -181,7 +188,7 @@ function Get-ISHPrerequisites
$filesToDownload | ForEach-Object {
$blobs+="$FolderPath$_"
}
Get-ISHAzureBlobObject -BlobName $blobs @hash | Out-Null
Get-ISHAzureBlobObject -BlobName $blobs @hash -Force:$Force | Out-Null
break
}
'No Download' {
Expand Down
6 changes: 5 additions & 1 deletion Source/Modules/ISHServer/ISHServer.12.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ $exportNames=@(
"Get-ISHServerFolderPath"
"Grant-ISHUserLogOnAsService"
"Get-ISHCOMPlus"
"Get-ISHNormalizedCredential"
#endregion

#region Ports
Expand All @@ -39,7 +40,10 @@ $exportNames=@(
"Get-ISHPrerequisites.ISH12"
"Initialize-ISHLocale"
"Initialize-ISHIIS"
"Initialize-ISHUser"
"Initialize-ISHUserLocalProfile"
"Set-ISHUserLocal"
"Set-ISHUserAdministrator"
"Initialize-ISHRegistry"
"Initialize-ISHMSDTCSettings"
"Initialize-ISHMSDTCTransactionTimeout"
#endregion
Expand Down
6 changes: 5 additions & 1 deletion Source/Modules/ISHServer/ISHServer.13.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ $exportNames=@(
"Get-ISHServerFolderPath"
"Grant-ISHUserLogOnAsService"
"Get-ISHCOMPlus"
"Get-ISHNormalizedCredential"
#endregion

#region Ports
Expand All @@ -39,7 +40,10 @@ $exportNames=@(
"Get-ISHPrerequisites.ISH13"
"Initialize-ISHLocale"
"Initialize-ISHIIS"
"Initialize-ISHUser"
"Initialize-ISHUserLocalProfile"
"Set-ISHUserLocal"
"Set-ISHUserAdministrator"
"Initialize-ISHRegistry"
#endregion

#region Install
Expand Down
42 changes: 42 additions & 0 deletions Source/Modules/ISHServer/Initialize-ISHRegistry.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<#
# 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 Initialize-ISHRegistry
{
[CmdletBinding()]
param (
)

begin
{
. $PSScriptRoot\Private\Test-RunningAsElevated.ps1
Test-RunningAsElevated -StopCallerPSCmdlet $PSCmdlet
}

process
{
# http://docs.sdl.com/LiveContent/content/en-US/SDL%20Knowledge%20Center%20full%20documentation-v2/GUID-70BAEF73-D2B4-488B-8F71-505DB8ACB244
Write-Debug "Disabling Force Unload of registry"
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System" -Name DisableForceUnload -Value $true
Write-Verbose "Disabled Force Unload of registry"
}

end
{

}
}
Loading

0 comments on commit ef7edb4

Please sign in to comment.