From 2c50cd463942392a744baa65187da265f4feb501 Mon Sep 17 00:00:00 2001 From: Dennis Lindqvist Date: Mon, 28 Aug 2023 11:59:26 +0200 Subject: [PATCH 1/2] feat: Added missing patches as error condition --- PSScriptAnalyzerSettings.psd1 | 2 +- README.md | 2 +- build.ps1 | 18 +- publish.ps1 | 4 +- src/psconfig.crescendo.json | 422 +++++++++++++++++----------------- version.txt | 2 +- 6 files changed, 225 insertions(+), 225 deletions(-) diff --git a/PSScriptAnalyzerSettings.psd1 b/PSScriptAnalyzerSettings.psd1 index 55c5021..e65ab5a 100644 --- a/PSScriptAnalyzerSettings.psd1 +++ b/PSScriptAnalyzerSettings.psd1 @@ -3,7 +3,7 @@ @{ 'Rules' = @{ 'PSAvoidUsingCmdletAliases' = @{ - 'allowlist' = @('foreach','select','where') + 'allowlist' = @('foreach','select','where','group','compare','sort','sleep') } } } diff --git a/README.md b/README.md index 39ad892..bff427b 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ A PowerShell wrapper for SharePoint Products Configuration Wizard, psconfig, cre * Clone the repo to your local system -* Dot Source the parse script the build +* Dot Source the output script to be able to build `. .\src\Invoke-ParseConfig.ps1` * Run the build script diff --git a/build.ps1 b/build.ps1 index c73c027..ea0a592 100644 --- a/build.ps1 +++ b/build.ps1 @@ -31,8 +31,8 @@ if (-not (Get-Item function:Invoke-ParseError)) { throw 'Missing functions' } -<# -$Commands = Get-ChildItem "$PSScriptRoot\src\*.json" | foreach { +<# +$Commands = Get-ChildItem "$PSScriptRoot\src\*.json" | foreach { $Definition = Get-Content $_.FullName | ConvertFrom-Json | Select -ExpandProperty Commands $Command = New-CrescendoCommand -Verb $Definition.Verb -Noun $Definition.Noun -OriginalName $Definition.OriginalName $Command.OriginalCommandElements = $Definition.OriginalCommandElements @@ -40,7 +40,7 @@ $Commands = Get-ChildItem "$PSScriptRoot\src\*.json" | foreach { if ($Definition.Parameters) { $Command.Parameters = $Definition.Parameters | ForEach-Object { - $Parameter = New-ParameterInfo -Name $_.Name -OriginalName $_.OriginalName + $Parameter = New-ParameterInfo -Name $_.Name -OriginalName $_.OriginalName $Parameter.OriginalName = $_.OriginalName $Parameter.OriginalPosition = $_.OriginalPosition $Parameter.ParameterType = $_.ParameterType @@ -50,7 +50,7 @@ $Commands = Get-ChildItem "$PSScriptRoot\src\*.json" | foreach { if ($Definition.OutputHandlers) { $Command.OutputHandlers = $Definition.OutputHandlers | ForEach-Object { - $Handler = New-OutputHandler + $Handler = New-OutputHandler $Handler.ParameterSetName = $_.ParameterSetName $Handler.Handler = $_.Handler $Handler.HandlerType = $_.HandlerType @@ -59,7 +59,7 @@ $Commands = Get-ChildItem "$PSScriptRoot\src\*.json" | foreach { } } - $Command + $Command } @{ @@ -67,13 +67,13 @@ $Commands = Get-ChildItem "$PSScriptRoot\src\*.json" | foreach { Commands = $Commands } | ConvertTo-Json -Depth 5 | Out-File "$obj\Commands.json" -Export-CrescendoModule -ConfigurationFile (Get-ChildItem "$obj\*.json") -ModuleName (Join-Path $Output 'PSConfig.Crescendo') -Force +Export-CrescendoModule -ConfigurationFile (Get-ChildItem "$obj\*.json") -ModuleName (Join-Path $Output 'PSConfig.Crescendo') -Force #> Export-CrescendoModule ` -ConfigurationFile $PSScriptRoot\src\PSConfig.Crescendo.json ` -ModuleName (Join-Path $Output 'PSConfig.Crescendo') ` - -Force + -Force $ManifestInfo = @{ ModuleVersion = $Version @@ -87,10 +87,10 @@ Export-CrescendoModule -ConfigurationFile (Get-ChildItem "$obj\*.json") -ModuleN #A URL to an icon representing this module. #IconUri = '' #ReleaseNotes of this module - #ReleaseNotes = '' + #ReleaseNotes = '' } -Update-ModuleManifest -Path (Join-Path $Output 'PSConfig.Crescendo.psd1') @ManifestInfo +Update-ModuleManifest -Path (Join-Path $Output 'PSConfig.Crescendo.psd1') @ManifestInfo Invoke-ScriptAnalyzer "$PSScriptRoot\output\PSConfig.Crescendo.psd1" -ExcludeRule PSAvoidTrailingWhitespace diff --git a/publish.ps1 b/publish.ps1 index ff6ad5b..c9addf8 100644 --- a/publish.ps1 +++ b/publish.ps1 @@ -1,2 +1,2 @@ -Rename-Item "$PSScriptRoot\output" -NewName "PSConfig.Crescendo" -Publish-Module -Path "$PSScriptRoot\PSConfig.Crescendo" -NuGetApiKey $Env:NUGETAPIKEY +Rename-Item "$PSScriptRoot\output" -NewName "PSConfig.Crescendo" +Publish-Module -Path "$PSScriptRoot\PSConfig.Crescendo" -NuGetApiKey $Env:NUGETAPIKEY diff --git a/src/psconfig.crescendo.json b/src/psconfig.crescendo.json index 2b9bf51..d23cd33 100644 --- a/src/psconfig.crescendo.json +++ b/src/psconfig.crescendo.json @@ -1,211 +1,211 @@ -{ - "$schema": "https://aka.ms/PowerShell/Crescendo/Schemas/2022-06", - "Commands": [ - { - "Verb": "Invoke", - "Noun": "PSConfigProductUpgrade", - "OriginalName": "psconfig.exe", - "OriginalCommandElements": [ - "-cmd", "upgrade" - ], - "Description": "Upgrade SharePoint Products using - -c:\\> psconfig -cmd upgrade - -and a selection of additional parameters.", - "Platform": ["Windows"], - "Elevation": null, - "DefaultParameterSetName": "default", - "Usage": null, - "Parameters": [ - { - "Name": "Inplace", - "OriginalName": "-inplace", - "ParameterType": "string", - "Description": "Perfoms an in-place upgrade (which means?). - -v2v as a value will perform an in-place upgrade version to version. -b2b as a value will perform an in-place upgrade build to build. " - }, - { - "Name": "Wait", - "OriginalName": "-wait", - "ParameterType": "switch", - "Description": "If not used, a Timer Job will be used in the background to perform the upgrade." - }, - { - "Name": "Force", - "OriginalName": "-force", - "ParameterType": "switch", - "Description": "Stops any currently running upgrade actions and the restarts the upgrade." - }, - { - "Name": "ResetContentDefinition", - "OriginalName": "-reghostonupgrade", - "ParameterType": "switch", - "Description": "Reset all content to the site definition version (what ever that means)." - }, - { - "Name": "KeepUserExperience", - "OriginalName": "-preserveoldusereexperience", - "ParameterType": "switch", - "Description": "Will keep the upgrade from upgrading to any new user experience available." - }, - { - "Name": "SetPassphrase", - "OriginalName": "-passphrase", - "ParameterType": "switch", - "Description": "Sets(?) the passphrase used to join the server farm. Must be the same on all servers." - } - ], - "Examples": [], - "OriginalText": null, - "HelpLinks": null, - "OutputHandlers": [ - { - "ParameterSetName": "default", - "HandlerType": "Function", - "Handler": "Invoke-ParseError" - } - ] - }, - { - "Verb": "Invoke", - "Noun": "PSConfigInstallApplicationContent", - "OriginalName": "psconfig.exe", - "OriginalCommandElements": [ - "-cmd", "applicationcontent", "-install" - ], - "Description": "Copies shared application data to existing Web applications using - -c:\\> psconfig -cmd applicationcontent -install", - "Platform": ["Windows"], - "Elevation": null, - "DefaultParameterSetName": "default", - "Usage": null, - "Parameters": null, - "Examples": [], - "OriginalText": null, - "HelpLinks": null, - "OutputHandlers": [ - { - "ParameterSetName": "default", - "HandlerType": "Function", - "Handler": "Invoke-ParseError" - } - ] - }, - { - "Verb": "Invoke", - "Noun": "PSConfigRegisterFeatures", - "OriginalName": "psconfig.exe", - "OriginalCommandElements": [ - "-cmd", "installfeatures" - ], - "Description": "Registers any SharePoint Products and Technologies features on this server with the -server farm using - -c:\\> psconfig -cmd installfeatures", - "Platform": ["Windows"], - "Elevation": null, - "DefaultParameterSetName": "default", - "Usage": null, - "Parameters": null, - "Examples": [], - "OriginalText": null, - "HelpLinks": null, - "OutputHandlers": [ - { - "ParameterSetName": "default", - "HandlerType": "Function", - "Handler": "Invoke-ParseError" - } - ] - }, - { - "Verb": "Invoke", - "Noun": "PSConfigSecureResourceFiles", - "OriginalName": "psconfig.exe", - "OriginalCommandElements": [ - "-cmd", "secureresources" - ], - "Description": "Perform SharePoint file and registry key security enforcement using - -c:\\> psconfig -cmd secureresources", - "Platform": ["Windows"], - "Elevation": null, - "DefaultParameterSetName": "default", - "Usage": null, - "Parameters": null, - "Examples": [], - "OriginalText": null, - "HelpLinks": null, - "OutputHandlers": [ - { - "ParameterSetName": "default", - "HandlerType": "Function", - "Handler": "Invoke-ParseError" - } - ] - }, - { - "Verb": "Invoke", - "Noun": "PSConfigRegisterServices", - "OriginalName": "psconfig.exe", - "OriginalCommandElements": [ - "-cmd", "services","-install" - ], - "Description": "Registers the local SharePoint services with the farm using - -c:\\> psconfig -cmd services -install", - "Platform": ["Windows"], - "Elevation": null, - "DefaultParameterSetName": "default", - "Usage": null, - "Parameters": null, - "Examples": [], - "OriginalText": null, - "HelpLinks": null, - "OutputHandlers": [ - { - "ParameterSetName": "default", - "HandlerType": "Function", - "Handler": "Invoke-ParseError" - } - ] - }, - { - "Verb": "Invoke", - "Noun": "PSConfigSafeProductUpgrade", - "OriginalName": "psconfig.exe", - "OriginalCommandElements": [ - "-cmd", "upgrade", "-inplace", "b2b", "-wait", "-force", - "-cmd", "applicationcontent", "-install", - "-cmd", "installfeatures", - "-cmd", "secureresources", - "-cmd", "services", "-install" - ], - "Description": "Applies all commands recommended to use after patching SharePoint using - -c:\\> psconfig -cmd upgrade -inplace b2b -wait -force -cmd applicationcontent -install --cmd installfeatures -cmd secureresources -cmd services -install", - "Platform": ["Windows"], - "Elevation": null, - "DefaultParameterSetName": "default", - "Usage": null, - "Parameters": null, - "Examples": [], - "OriginalText": null, - "HelpLinks": null, - "OutputHandlers": [ - { - "ParameterSetName": "default", - "HandlerType": "Function", - "Handler": "Invoke-ParseError" - } - ] - - } - - ] -} +{ + "$schema": "https://aka.ms/PowerShell/Crescendo/Schemas/2022-06", + "Commands": [ + { + "Verb": "Invoke", + "Noun": "PSConfigProductUpgrade", + "OriginalName": "psconfig.exe", + "OriginalCommandElements": [ + "-cmd", "upgrade" + ], + "Description": "Upgrade SharePoint Products using + +c:\\> psconfig -cmd upgrade + +and a selection of additional parameters.", + "Platform": ["Windows"], + "Elevation": null, + "DefaultParameterSetName": "default", + "Usage": null, + "Parameters": [ + { + "Name": "Inplace", + "OriginalName": "-inplace", + "ParameterType": "string", + "Description": "Perfoms an in-place upgrade (which means?). + +v2v as a value will perform an in-place upgrade version to version. +b2b as a value will perform an in-place upgrade build to build." + }, + { + "Name": "Wait", + "OriginalName": "-wait", + "ParameterType": "switch", + "Description": "If not used, a Timer Job will be used in the background to perform the upgrade." + }, + { + "Name": "Force", + "OriginalName": "-force", + "ParameterType": "switch", + "Description": "Stops any currently running upgrade actions and the restarts the upgrade." + }, + { + "Name": "ResetContentDefinition", + "OriginalName": "-reghostonupgrade", + "ParameterType": "switch", + "Description": "Reset all content to the site definition version (what ever that means)." + }, + { + "Name": "KeepUserExperience", + "OriginalName": "-preserveoldusereexperience", + "ParameterType": "switch", + "Description": "Will keep the upgrade from upgrading to any new user experience available." + }, + { + "Name": "SetPassphrase", + "OriginalName": "-passphrase", + "ParameterType": "switch", + "Description": "Sets(?) the passphrase used to join the server farm. Must be the same on all servers." + } + ], + "Examples": [], + "OriginalText": null, + "HelpLinks": null, + "OutputHandlers": [ + { + "ParameterSetName": "default", + "HandlerType": "Function", + "Handler": "Invoke-ParseError" + } + ] + }, + { + "Verb": "Invoke", + "Noun": "PSConfigInstallApplicationContent", + "OriginalName": "psconfig.exe", + "OriginalCommandElements": [ + "-cmd", "applicationcontent", "-install" + ], + "Description": "Copies shared application data to existing Web applications using + +c:\\> psconfig -cmd applicationcontent -install", + "Platform": ["Windows"], + "Elevation": null, + "DefaultParameterSetName": "default", + "Usage": null, + "Parameters": null, + "Examples": [], + "OriginalText": null, + "HelpLinks": null, + "OutputHandlers": [ + { + "ParameterSetName": "default", + "HandlerType": "Function", + "Handler": "Invoke-ParseError" + } + ] + }, + { + "Verb": "Invoke", + "Noun": "PSConfigRegisterFeatures", + "OriginalName": "psconfig.exe", + "OriginalCommandElements": [ + "-cmd", "installfeatures" + ], + "Description": "Registers any SharePoint Products and Technologies features on this server with the +server farm using + +c:\\> psconfig -cmd installfeatures", + "Platform": ["Windows"], + "Elevation": null, + "DefaultParameterSetName": "default", + "Usage": null, + "Parameters": null, + "Examples": [], + "OriginalText": null, + "HelpLinks": null, + "OutputHandlers": [ + { + "ParameterSetName": "default", + "HandlerType": "Function", + "Handler": "Invoke-ParseError" + } + ] + }, + { + "Verb": "Invoke", + "Noun": "PSConfigSecureResourceFiles", + "OriginalName": "psconfig.exe", + "OriginalCommandElements": [ + "-cmd", "secureresources" + ], + "Description": "Perform SharePoint file and registry key security enforcement using + +c:\\> psconfig -cmd secureresources", + "Platform": ["Windows"], + "Elevation": null, + "DefaultParameterSetName": "default", + "Usage": null, + "Parameters": null, + "Examples": [], + "OriginalText": null, + "HelpLinks": null, + "OutputHandlers": [ + { + "ParameterSetName": "default", + "HandlerType": "Function", + "Handler": "Invoke-ParseError" + } + ] + }, + { + "Verb": "Invoke", + "Noun": "PSConfigRegisterServices", + "OriginalName": "psconfig.exe", + "OriginalCommandElements": [ + "-cmd", "services","-install" + ], + "Description": "Registers the local SharePoint services with the farm using + +c:\\> psconfig -cmd services -install", + "Platform": ["Windows"], + "Elevation": null, + "DefaultParameterSetName": "default", + "Usage": null, + "Parameters": null, + "Examples": [], + "OriginalText": null, + "HelpLinks": null, + "OutputHandlers": [ + { + "ParameterSetName": "default", + "HandlerType": "Function", + "Handler": "Invoke-ParseError" + } + ] + }, + { + "Verb": "Invoke", + "Noun": "PSConfigSafeProductUpgrade", + "OriginalName": "psconfig.exe", + "OriginalCommandElements": [ + "-cmd", "upgrade", "-inplace", "b2b", "-wait", "-force", + "-cmd", "applicationcontent", "-install", + "-cmd", "installfeatures", + "-cmd", "secureresources", + "-cmd", "services", "-install" + ], + "Description": "Applies all commands recommended to use after patching SharePoint using + +c:\\> psconfig -cmd upgrade -inplace b2b -wait -force -cmd applicationcontent -install +-cmd installfeatures -cmd secureresources -cmd services -install", + "Platform": ["Windows"], + "Elevation": null, + "DefaultParameterSetName": "default", + "Usage": null, + "Parameters": null, + "Examples": [], + "OriginalText": null, + "HelpLinks": null, + "OutputHandlers": [ + { + "ParameterSetName": "default", + "HandlerType": "Function", + "Handler": "Invoke-ParseError" + } + ] + + } + + ] +} diff --git a/version.txt b/version.txt index 845639e..0ea3a94 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.1.4 +0.2.0 From be71e9c8aded87afa7a2713f846cb3db610e2cd3 Mon Sep 17 00:00:00 2001 From: Dennis Lindqvist Date: Mon, 28 Aug 2023 12:00:23 +0200 Subject: [PATCH 2/2] fix: Added missing changes --- build.ps1 | 2 +- src/Invoke-ParsePSConfig.ps1 | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build.ps1 b/build.ps1 index ea0a592..dd20d84 100644 --- a/build.ps1 +++ b/build.ps1 @@ -20,7 +20,7 @@ foreach ($Module in $Modules) { -ErrorAction SilentlyContinue if (-not $ModuleExist) { - Install-Module $Module.Name -RequiredVersion $Mdoule.Version -AllowPrerelease -Force -Scope CurrentUser + Install-Module $Module.Name -RequiredVersion $Module.Version -AllowPrerelease -Force -Scope CurrentUser } } diff --git a/src/Invoke-ParsePSConfig.ps1 b/src/Invoke-ParsePSConfig.ps1 index 2a7a720..b3591c1 100644 --- a/src/Invoke-ParsePSConfig.ps1 +++ b/src/Invoke-ParsePSConfig.ps1 @@ -5,16 +5,16 @@ [Parameter()] [string[]]$InputString ) -<# +<# $logs = $InputString -like '*located*' | # get all lines containing a log file location foreach {# and extract the log file path $_ -replace "`n",'' -replace "`r",'' -split 'located' | select -index 1 - } | + } | foreach { $_ -split ' ' | select -Index 2 } #> - $InputString -match 'error|exception|throw|invalid|fail|diagnostic' | + $InputString -match 'error|exception|throw|invalid|fail|diagnostic|missing' | where {$_ -notlike '*success*'} | foreach { write-error -Message $_