Skip to content

Commit

Permalink
Fixing #1420 and #1422
Browse files Browse the repository at this point in the history
  • Loading branch information
ykuijs committed Mar 17, 2023
1 parent 3882797 commit 929b588
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 28 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- Export
- Fixed issue where the export would not run on Subscription Edition
- SPInstallPrereqs
- Fix issue where a failed VC++ upgrade results in two versions being present, which
the code didn't handle properly
- SPPublishServiceApplication
- Fixed issue where the Set method never did anything because it was checking incorrect
values
- SPShellAdmins
- Fix issue where Get-SPDatabase could not be found
- SPUserProfileServiceApp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@ function Set-TargetResource
throw $message
}

if ($Ensure -eq "Present")
if ($params.Ensure -eq "Present")
{
Write-Verbose -Message "Publishing Service Application $Name"
Publish-SPServiceApplication -Identity $serviceApp
}

if ($Ensure -eq "Absent")
if ($params.Ensure -eq "Absent")
{
Write-Verbose -Message "Unpublishing Service Application $Name"
Unpublish-SPServiceApplication -Identity $serviceApp
Expand Down
55 changes: 29 additions & 26 deletions SharePointDsc/Modules/SharePointDsc.Util/SharePointDsc.Util.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ function Get-SPDscFarmAccount
[System.Reflection.BindingFlags]::Instance -bor `
[System.Reflection.BindingFlags]::NonPublic

$pw = $account.GetType().GetField("m_Password", $bindings).GetValue($account);
$pw = $account.GetType().GetField("m_Password", $bindings).GetValue($account)

return New-Object -TypeName System.Management.Automation.PSCredential `
-ArgumentList $farmaccount, $pw.SecureStringValue
Expand Down Expand Up @@ -533,18 +533,18 @@ function Get-SPDscServerPatchStatus
$farm = Get-SPFarm
$productVersions = [Microsoft.SharePoint.Administration.SPProductVersions]::GetProductVersions($farm)
$server = Get-SPServer $env:COMPUTERNAME
$serverProductInfo = $productVersions.GetServerProductInfo($server.Id);
$serverProductInfo = $productVersions.GetServerProductInfo($server.Id)
if ($null -ne $serverProductInfo)
{
$statusType = $serverProductInfo.InstallStatus;
$statusType = $serverProductInfo.InstallStatus
if ($statusType -ne 0)
{
$statusType = $serverProductInfo.GetUpgradeStatus($farm, $server);
$statusType = $serverProductInfo.GetUpgradeStatus($farm, $server)
}
}
else
{
$statusType = [Microsoft.SharePoint.Administration.SPServerProductInfo+StatusType]::NoActionRequired;
$statusType = [Microsoft.SharePoint.Administration.SPServerProductInfo+StatusType]::NoActionRequired
}

return $statusType
Expand All @@ -561,22 +561,22 @@ function Get-SPDscAllServersPatchStatus
[array]$srvStatus = @()
foreach ($server in $servers)
{
$serverProductInfo = $productVersions.GetServerProductInfo($server.Id);
$serverProductInfo = $productVersions.GetServerProductInfo($server.Id)
if ($null -ne $serverProductInfo)
{
$statusType = $serverProductInfo.InstallStatus;
$statusType = $serverProductInfo.InstallStatus
if ($statusType -ne 0)
{
$statusType = $serverProductInfo.GetUpgradeStatus($farm, $server);
$statusType = $serverProductInfo.GetUpgradeStatus($farm, $server)
}
}
else
{
$statusType = [Microsoft.SharePoint.Administration.SPServerProductInfo+StatusType]::NoActionRequired;
$statusType = [Microsoft.SharePoint.Administration.SPServerProductInfo+StatusType]::NoActionRequired
}

$srvStatus += [PSCustomObject]@{
Name = $server.Name
Name = $server.Name
Status = $statusType
}
}
Expand Down Expand Up @@ -1674,36 +1674,39 @@ function Export-SPConfiguration
$Global:spFarmAccount = ""

$sharePointSnapin = Get-PSSnapin | Where-Object { $_.Name -eq "Microsoft.SharePoint.PowerShell" }
if ($null -ne $sharePointSnapin)
if ($null -eq $sharePointSnapin)
{
if ($Quiet -or $ComponentsToExtract.Count -gt 0)
$sharePointModule = Get-Module SharePointServer -ListAvailable
if ($null -eq $sharePointModule)
{
if ($StandAlone)
Write-Host -Object " - We couldn't detect a SharePoint installation on this machine. Please execute the SharePoint ReverseDSC script on an existing SharePoint server." -BackgroundColor Red -ForegroundColor Black
return
}
}

if ($Quiet -or $ComponentsToExtract.Count -gt 0)
{
if ($StandAlone)
{
if ($DynamicCompilation)
{
if ($DynamicCompilation)
{
Get-SPReverseDSC -ComponentsToExtract $ComponentsToExtract -Credentials $Credentials -OutputPath $OutputPath -Standalone -DynamicCompilation -ProductKey $ProductKey -BinaryLocation $BinaryLocation
}
else
{
Get-SPReverseDSC -ComponentsToExtract $ComponentsToExtract -Credentials $Credentials -OutputPath $OutputPath -Standalone -ProductKey $ProductKey -BinaryLocation $BinaryLocation
}
Get-SPReverseDSC -ComponentsToExtract $ComponentsToExtract -Credentials $Credentials -OutputPath $OutputPath -Standalone -DynamicCompilation -ProductKey $ProductKey -BinaryLocation $BinaryLocation
}
else
{
Get-SPReverseDSC -ComponentsToExtract $ComponentsToExtract -Credentials $Credentials -OutputPath $OutputPath -ProductKey $ProductKey -BinaryLocation $BinaryLocation
Get-SPReverseDSC -ComponentsToExtract $ComponentsToExtract -Credentials $Credentials -OutputPath $OutputPath -Standalone -ProductKey $ProductKey -BinaryLocation $BinaryLocation
}
}
else
{
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null
[System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") | Out-Null
DisplayGUI
Get-SPReverseDSC -ComponentsToExtract $ComponentsToExtract -Credentials $Credentials -OutputPath $OutputPath -ProductKey $ProductKey -BinaryLocation $BinaryLocation
}
}
else
{
Write-Host -Object " - We couldn't detect a SharePoint installation on this machine. Please execute the SharePoint ReverseDSC script on an existing SharePoint server." -BackgroundColor Red -ForegroundColor Black
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null
[System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") | Out-Null
DisplayGUI
}
}

Expand Down

0 comments on commit 929b588

Please sign in to comment.