Skip to content

Commit

Permalink
Merge pull request #1210 from ykuijs/master
Browse files Browse the repository at this point in the history
Bugfix PR
  • Loading branch information
ykuijs authored Jun 2, 2020
2 parents 9c1259f + 94471e3 commit 89fea3b
Show file tree
Hide file tree
Showing 16 changed files with 975 additions and 859 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Re-enabled Unit tests for Sharepoint 2016 and 2019
- SPAppCatalog
- Added more logging in the Get method to ease troubleshooting
- SPServiceInstance
- Added logic to wait for a service start/stop, to make sure no conflicts
can occur because of the asynchronous nature of service instance starts.

### Changed

- SPProductUpdate
- Updated Get method to display a Verbose message when the setup file is
not found
- SPWebAppPermissions
- Changed Get method not to throw an exception when the web application
cannot be found to prevent issue
- SPWebAppSuiteBar
- This resource does not work on SharePoint 2019. Changed resource to display
a Verbose message when on 2019

### Fixed

Expand All @@ -28,13 +37,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed issue with logging to the custom event log where the event log
wasn't created correctly.
- Fixed various unit tests for Sharepoint 2016 and 2019
- Corrected export of Get-SPDscInstalledProductVersion function, which is used
by ReverseDsc
- SPConfigWizard
- Fixed a call to Get-SPFarm without loading the snap-in first
- SPInstallLanguagePack
- Fixed issue with detection of Chinese language pack in SharePoint 2019
- SPSite
- Fixed issue where the default groups were checked, even though
that parameter wasn't specified in the config
- Fixed issue where the Get method threw an error when the site owner was
still in classic format (caused by an earlier migration).
- SPTrustedSecurityTokenIssuer
- Fixed incorrect storing the default value of IsTrustBroker in the Set
and Test method

### Removed

Expand Down
2 changes: 1 addition & 1 deletion RequiredModules.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

invokeBuild = 'latest'
PSScriptAnalyzer = 'latest'
pester = 'latest'
pester = '4.10.1'
Plaster = 'latest'
ModuleBuilder = '1.0.0'
ChangelogManagement = 'latest'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@ function Get-TargetResource
Write-Verbose -Message "Check if the setup file exists"
if (-not(Test-Path -Path $SetupFile))
{
throw "Setup file cannot be found: {$SetupFile}"
return @{
SetupFile = $SetupFile
ShutdownServices = $ShutdownServices
BinaryInstallDays = $BinaryInstallDays
BinaryInstallTime = $BinaryInstallTime
Ensure = "Absent"
}
}

Write-Verbose -Message "Checking file status of $SetupFile"
Expand Down Expand Up @@ -656,7 +662,6 @@ function Test-TargetResource
if ($Ensure -eq "Absent")
{
throw [Exception] "SharePoint does not support uninstalling updates."
return
}

$CurrentValues = Get-TargetResource @PSBoundParameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ function Set-TargetResource
$params = $args[0]
$newName = $args[1]

$si = Get-SPServiceInstance -Server $env:COMPUTERNAME -All | Where-Object -FilterScript {
$computerName = $env:COMPUTERNAME
$si = Get-SPServiceInstance -Server $computerName -All | Where-Object -FilterScript {
$_.TypeName -eq $params.Name -or `
$_.TypeName -eq $newName -or `
$_.GetType().Name -eq $newName
Expand All @@ -120,18 +121,40 @@ function Set-TargetResource
if ($null -eq $si)
{
$domain = (Get-CimInstance -ClassName Win32_ComputerSystem).Domain
$fqdn = "$($env:COMPUTERNAME).$domain"
$si = Get-SPServiceInstance -Server $fqdn -All | Where-Object -FilterScript {
$computerName = "$($env:COMPUTERNAME).$domain"
$si = Get-SPServiceInstance -Server $computerName -All | Where-Object -FilterScript {
$_.TypeName -eq $params.Name -or `
$_.TypeName -eq $newName -or `
$_.GetType().Name -eq $newName
}
}

if ($null -eq $si)
{
throw [Exception] "Unable to locate service instance '$($params.Name)'"
}

Start-SPServiceInstance -Identity $si

# Waiting for the service to start before continuing (max 30 minutes)
$serviceCheck = Get-SPServiceInstance -Server $si.Server.Name -All | Where-Object -FilterScript {
$_.TypeName -eq $si.TypeName
}

$count = 0
$maxCount = 30

while (($count -lt $maxCount) -and ($serviceCheck.Status -ne "Online"))
{
Write-Verbose -Message ("$([DateTime]::Now.ToShortTimeString()) - Waiting " + `
"for service instance to start. Current status: $($serviceCheck.Status) " + `
"(waited $count of $maxCount minutes)")
Start-Sleep -Seconds 60
$serviceCheck = Get-SPServiceInstance -Server $si.Server.Name -All | Where-Object -FilterScript {
$_.TypeName -eq $si.TypeName
}
$count++
}
}
}
else
Expand Down Expand Up @@ -163,6 +186,26 @@ function Set-TargetResource
throw [Exception] "Unable to locate service instance '$($params.Name)'"
}
Stop-SPServiceInstance -Identity $si

# Waiting for the service to stop before continuing (max 30 minutes)
$serviceCheck = Get-SPServiceInstance -Server $si.Server.Name -All | Where-Object -FilterScript {
$_.TypeName -eq $si.TypeName
}

$count = 0
$maxCount = 30

while (($count -lt $maxCount) -and ($serviceCheck.Status -ne "Disabled"))
{
Write-Verbose -Message ("$([DateTime]::Now.ToShortTimeString()) - Waiting " + `
"for service instance to stop. Current status: $($serviceCheck.Status) " + `
"(waited $count of $maxCount minutes)")
Start-Sleep -Seconds 60
$serviceCheck = Get-SPServiceInstance -Server $si.Server.Name -All | Where-Object -FilterScript {
$_.TypeName -eq $si.TypeName
}
$count++
}
}
}
}
Expand Down
Loading

0 comments on commit 89fea3b

Please sign in to comment.