diff --git a/Build/Manage-Module.ps1 b/Build/Manage-Module.ps1 index 79d0e1c..25dd6b7 100644 --- a/Build/Manage-Module.ps1 +++ b/Build/Manage-Module.ps1 @@ -1,290 +1,221 @@ Clear-Host -$Configuration = @{ - Information = @{ - ModuleName = 'GPOZaurr' - DirectoryProjects = 'C:\Support\GitHub' +Import-Module "PSPublishModule" -Force - FunctionsToExport = 'Public' - AliasesToExport = 'Public' +Invoke-ModuleBuild -ModuleName 'GPOZaurr' { + # Usual defaults as per standard module + $Manifest = @{ + # Version number of this module. + ModuleVersion = '1.X.0' + # Supported PSEditions + CompatiblePSEditions = @('Desktop') + # ID used to uniquely identify this module + GUID = 'f7d4c9e4-0298-4f51-ad77-e8e3febebbde' + # Author of this module + Author = 'Przemyslaw Klys' + # Company or vendor of this module + CompanyName = 'Evotec' + # Copyright statement for this module + Copyright = "(c) 2011 - $((Get-Date).Year) Przemyslaw Klys @ Evotec. All rights reserved." + # Description of the functionality provided by this module + Description = 'Group Policy Eater is a PowerShell module that aims to gather information about Group Policies but also allows fixing issues that you may find in them.' + # Minimum version of the Windows PowerShell engine required by this module + PowerShellVersion = '5.1' + # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. + Tags = @('Windows', 'ActiveDirectory', 'GPO', 'GroupPolicy') + #IconUri = 'https://evotec.xyz/wp-content/uploads/2019/02/PSPublishModule.png' - Manifest = @{ - # Version number of this module. - ModuleVersion = '0.0.X' - # Supported PSEditions - CompatiblePSEditions = @('Desktop') - # ID used to uniquely identify this module - GUID = 'f7d4c9e4-0298-4f51-ad77-e8e3febebbde' - # Author of this module - Author = 'Przemyslaw Klys' - # Company or vendor of this module - CompanyName = 'Evotec' - # Copyright statement for this module - Copyright = "(c) 2011 - $((Get-Date).Year) Przemyslaw Klys @ Evotec. All rights reserved." - # Description of the functionality provided by this module - Description = 'Group Policy Eater is a PowerShell module that aims to gather information about Group Policies but also allows fixing issues that you may find in them.' - # Minimum version of the Windows PowerShell engine required by this module - PowerShellVersion = '5.1' - # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. - Tags = @('Windows', 'ActiveDirectory', 'GPO', 'GroupPolicy') - #IconUri = 'https://evotec.xyz/wp-content/uploads/2019/02/PSPublishModule.png' - - ProjectUri = 'https://github.com/EvotecIT/GPOZaurr' - - RequiredModules = @( - @{ ModuleName = 'PSSharedGoods'; ModuleVersion = 'Latest'; Guid = 'ee272aa8-baaa-4edf-9f45-b6d6f7d844fe' } - @{ ModuleName = 'ADEssentials'; ModuleVersion = '0.0.148'; Guid = '9fc9fd61-7f11-4f4b-a527-084086f1905f' } - @{ ModuleName = 'PSWriteHTML'; ModuleVersion = "Latest"; Guid = 'a7bdf640-f5cb-4acf-9de0-365b322d245c' } - ) - ExternalModuleDependencies = @( - #"ActiveDirectory" - #"GroupPolicy" - "CimCmdlets" - 'Microsoft.PowerShell.Management' - 'Microsoft.PowerShell.Utility' - 'Microsoft.PowerShell.Security' - ) - CommandModuleDependencies = @{ - ActiveDirectory = @( - 'Add-GPOPermission' - 'Add-GPOZaurrPermission' - 'Backup-GPOZaurr' - 'Clear-GPOZaurrSysvolDFSR' - 'ConvertFrom-CSExtension' - 'Find-CSExtension' - 'Get-GPOZaurr' - 'Get-GPOZaurrAD' - 'Get-GPOZaurrBackupInformation' - 'Get-GPOZaurrBroken' - 'Get-GPOZaurrDictionary' - 'Get-GPOZaurrDuplicateObject' - 'Get-GPOZaurrFiles' - 'Get-GPOZaurrFilesPolicyDefinition' - 'Get-GPOZaurrFolders' - 'Get-GPOZaurrInheritance' - 'Get-GPOZaurrLegacyFiles' - 'Get-GPOZaurrLink' - 'Get-GPOZaurrLinkSummary' - 'Get-GPOZaurrNetLogon' - 'Get-GPOZaurrOwner' - 'Get-GPOZaurrPassword' - 'Get-GPOZaurrPermission' - 'Get-GPOZaurrPermissionConsistency' - 'Get-GPOZaurrPermissionRoot' - 'Get-GPOZaurrPermissionSummary' - 'Get-GPOZaurrSysvolDFSR' - 'Get-GPOZaurrWMI' - 'Invoke-GPOZaurr' - #'Invoke-GPOZaurrContent' - 'Invoke-GPOZaurrPermission' - 'Invoke-GPOZaurrSupport' - 'New-GPOZaurrWMI' - 'Optimize-GPOZaurr' - 'Remove-GPOPermission' - 'Remove-GPOZaurr' - 'Remove-GPOZaurrBroken' - 'Remove-GPOZaurrDuplicateObject' - 'Remove-GPOZaurrFolders' - 'Remove-GPOZaurrLegacyFiles' - 'Remove-GPOZaurrPermission' - 'Remove-GPOZaurrWMI' - 'Repair-GPOZaurrNetLogonOwner' - 'Repair-GPOZaurrPermissionConsistency' - 'Restore-GPOZaurr' - 'Save-GPOZaurrFiles' - 'Set-GPOOwner' - 'Set-GPOZaurrOwner' - 'Find-GPO' - 'Get-GPOZaurrFilesPolicyDefinitions' - 'Get-GPOZaurrSysvol' - 'Remove-GPOZaurrOrphaned' - 'Show-GPO' - 'Show-GPOZaurr' - ) - GroupPolicy = @( - 'Add-GPOPermission' - 'Add-GPOZaurrPermission' - 'Backup-GPOZaurr' - 'Clear-GPOZaurrSysvolDFSR' - 'ConvertFrom-CSExtension' - 'Find-CSExtension' - 'Get-GPOZaurr' - 'Get-GPOZaurrAD' - 'Get-GPOZaurrBackupInformation' - 'Get-GPOZaurrBroken' - 'Get-GPOZaurrDictionary' - 'Get-GPOZaurrDuplicateObject' - 'Get-GPOZaurrFiles' - 'Get-GPOZaurrFilesPolicyDefinition' - 'Get-GPOZaurrFolders' - 'Get-GPOZaurrInheritance' - 'Get-GPOZaurrLegacyFiles' - 'Get-GPOZaurrLink' - 'Get-GPOZaurrLinkSummary' - 'Get-GPOZaurrNetLogon' - 'Get-GPOZaurrOwner' - 'Get-GPOZaurrPassword' - 'Get-GPOZaurrPermission' - 'Get-GPOZaurrPermissionConsistency' - 'Get-GPOZaurrPermissionRoot' - 'Get-GPOZaurrPermissionSummary' - 'Get-GPOZaurrSysvolDFSR' - 'Get-GPOZaurrWMI' - 'Invoke-GPOZaurr' - #'Invoke-GPOZaurrContent' - 'Invoke-GPOZaurrPermission' - 'Invoke-GPOZaurrSupport' - 'New-GPOZaurrWMI' - 'Optimize-GPOZaurr' - 'Remove-GPOPermission' - 'Remove-GPOZaurr' - 'Remove-GPOZaurrBroken' - 'Remove-GPOZaurrDuplicateObject' - 'Remove-GPOZaurrFolders' - 'Remove-GPOZaurrLegacyFiles' - 'Remove-GPOZaurrPermission' - 'Remove-GPOZaurrWMI' - 'Repair-GPOZaurrNetLogonOwner' - 'Repair-GPOZaurrPermissionConsistency' - 'Restore-GPOZaurr' - 'Save-GPOZaurrFiles' - 'Set-GPOOwner' - 'Set-GPOZaurrOwner' - 'Find-GPO' - 'Get-GPOZaurrFilesPolicyDefinitions' - 'Get-GPOZaurrSysvol' - 'Remove-GPOZaurrOrphaned' - 'Show-GPO' - 'Show-GPOZaurr' - ) - } - } + ProjectUri = 'https://github.com/EvotecIT/GPOZaurr' } - Options = @{ - Merge = @{ - Sort = 'None' - FormatCodePSM1 = @{ - Enabled = $true - RemoveComments = $false - FormatterSettings = @{ - IncludeRules = @( - 'PSPlaceOpenBrace', - 'PSPlaceCloseBrace', - 'PSUseConsistentWhitespace', - 'PSUseConsistentIndentation', - 'PSAlignAssignmentStatement', - 'PSUseCorrectCasing' - ) + New-ConfigurationManifest @Manifest - Rules = @{ - PSPlaceOpenBrace = @{ - Enable = $true - OnSameLine = $true - NewLineAfter = $true - IgnoreOneLineBlock = $true - } + New-ConfigurationModule -Type RequiredModule -Name 'PSWriteColor', 'PSSharedGoods', 'ADEssentials' -Guid Auto -Version Latest + #New-ConfigurationModule -Type ExternalModule -Name 'Microsoft.PowerShell.Utility', 'Microsoft.PowerShell.Management','Microsoft.PowerShell.Security' + New-ConfigurationModule -Type ApprovedModule -Name 'PSWriteColor', 'Connectimo', 'PSUnifi', 'PSWebToolbox', 'PSMyPassword' - PSPlaceCloseBrace = @{ - Enable = $true - NewLineAfter = $false - IgnoreOneLineBlock = $true - NoEmptyLineBefore = $false - } + New-ConfigurationModule -Type ExternalModule -Name @( + "CimCmdlets" + 'Microsoft.PowerShell.Management' + 'Microsoft.PowerShell.Utility' + 'Microsoft.PowerShell.Security' + ) - PSUseConsistentIndentation = @{ - Enable = $true - Kind = 'space' - PipelineIndentation = 'IncreaseIndentationAfterEveryPipeline' - IndentationSize = 4 - } + New-ConfigurationModuleSkip -IgnoreModuleName @( + # this are builtin into PowerShell, so not critical + 'powershellget' + 'GroupPolicy' + 'ActiveDirectory' + ) -IgnoreFunctionName @( - PSUseConsistentWhitespace = @{ - Enable = $true - CheckInnerBrace = $true - CheckOpenBrace = $true - CheckOpenParen = $true - CheckOperator = $true - CheckPipe = $true - CheckSeparator = $true - } + ) - PSAlignAssignmentStatement = @{ - Enable = $true - CheckHashtable = $true - } + New-ConfigurationCommand -ModuleName 'ActiveDirectory' -CommandName @( + 'Add-GPOPermission' + 'Add-GPOZaurrPermission' + 'Backup-GPOZaurr' + 'Clear-GPOZaurrSysvolDFSR' + 'ConvertFrom-CSExtension' + 'Find-CSExtension' + 'Get-GPOZaurr' + 'Get-GPOZaurrAD' + 'Get-GPOZaurrBackupInformation' + 'Get-GPOZaurrBroken' + 'Get-GPOZaurrDictionary' + 'Get-GPOZaurrDuplicateObject' + 'Get-GPOZaurrFiles' + 'Get-GPOZaurrFilesPolicyDefinition' + 'Get-GPOZaurrFolders' + 'Get-GPOZaurrInheritance' + 'Get-GPOZaurrLegacyFiles' + 'Get-GPOZaurrLink' + 'Get-GPOZaurrLinkSummary' + 'Get-GPOZaurrNetLogon' + 'Get-GPOZaurrOwner' + 'Get-GPOZaurrPassword' + 'Get-GPOZaurrPermission' + 'Get-GPOZaurrPermissionConsistency' + 'Get-GPOZaurrPermissionRoot' + 'Get-GPOZaurrPermissionSummary' + 'Get-GPOZaurrSysvolDFSR' + 'Get-GPOZaurrWMI' + 'Invoke-GPOZaurr' + #'Invoke-GPOZaurrContent' + 'Invoke-GPOZaurrPermission' + 'Invoke-GPOZaurrSupport' + 'New-GPOZaurrWMI' + 'Optimize-GPOZaurr' + 'Remove-GPOPermission' + 'Remove-GPOZaurr' + 'Remove-GPOZaurrBroken' + 'Remove-GPOZaurrDuplicateObject' + 'Remove-GPOZaurrFolders' + 'Remove-GPOZaurrLegacyFiles' + 'Remove-GPOZaurrPermission' + 'Remove-GPOZaurrWMI' + 'Repair-GPOZaurrNetLogonOwner' + 'Repair-GPOZaurrPermissionConsistency' + 'Restore-GPOZaurr' + 'Save-GPOZaurrFiles' + 'Set-GPOOwner' + 'Set-GPOZaurrOwner' + 'Find-GPO' + 'Get-GPOZaurrFilesPolicyDefinitions' + 'Get-GPOZaurrSysvol' + 'Remove-GPOZaurrOrphaned' + 'Show-GPO' + 'Show-GPOZaurr' + ) + New-ConfigurationCommand -ModuleName 'GroupPolicy' -CommandName @( + 'Add-GPOPermission' + 'Add-GPOZaurrPermission' + 'Backup-GPOZaurr' + 'Clear-GPOZaurrSysvolDFSR' + 'ConvertFrom-CSExtension' + 'Find-CSExtension' + 'Get-GPOZaurr' + 'Get-GPOZaurrAD' + 'Get-GPOZaurrBackupInformation' + 'Get-GPOZaurrBroken' + 'Get-GPOZaurrDictionary' + 'Get-GPOZaurrDuplicateObject' + 'Get-GPOZaurrFiles' + 'Get-GPOZaurrFilesPolicyDefinition' + 'Get-GPOZaurrFolders' + 'Get-GPOZaurrInheritance' + 'Get-GPOZaurrLegacyFiles' + 'Get-GPOZaurrLink' + 'Get-GPOZaurrLinkSummary' + 'Get-GPOZaurrNetLogon' + 'Get-GPOZaurrOwner' + 'Get-GPOZaurrPassword' + 'Get-GPOZaurrPermission' + 'Get-GPOZaurrPermissionConsistency' + 'Get-GPOZaurrPermissionRoot' + 'Get-GPOZaurrPermissionSummary' + 'Get-GPOZaurrSysvolDFSR' + 'Get-GPOZaurrWMI' + 'Invoke-GPOZaurr' + #'Invoke-GPOZaurrContent' + 'Invoke-GPOZaurrPermission' + 'Invoke-GPOZaurrSupport' + 'New-GPOZaurrWMI' + 'Optimize-GPOZaurr' + 'Remove-GPOPermission' + 'Remove-GPOZaurr' + 'Remove-GPOZaurrBroken' + 'Remove-GPOZaurrDuplicateObject' + 'Remove-GPOZaurrFolders' + 'Remove-GPOZaurrLegacyFiles' + 'Remove-GPOZaurrPermission' + 'Remove-GPOZaurrWMI' + 'Repair-GPOZaurrNetLogonOwner' + 'Repair-GPOZaurrPermissionConsistency' + 'Restore-GPOZaurr' + 'Save-GPOZaurrFiles' + 'Set-GPOOwner' + 'Set-GPOZaurrOwner' + 'Find-GPO' + 'Get-GPOZaurrFilesPolicyDefinitions' + 'Get-GPOZaurrSysvol' + 'Remove-GPOZaurrOrphaned' + 'Show-GPO' + 'Show-GPOZaurr' + ) - PSUseCorrectCasing = @{ - Enable = $true - } - } - } - } - FormatCodePSD1 = @{ - Enabled = $true - RemoveComments = $false - } - Integrate = @{ - ApprovedModules = 'PSSharedGoods', 'PSWriteColor', 'Connectimo', 'PSUnifi', 'PSWebToolbox', 'PSMyPassword', 'ADEssentials', 'PSPublishModule' - } - } - Standard = @{ - FormatCodePSM1 = @{ - } - FormatCodePSD1 = @{ - Enabled = $true - #RemoveComments = $true - } - } - PowerShellGallery = @{ - ApiKey = 'C:\Support\Important\PowerShellGalleryAPI.txt' - FromFile = $true - } - GitHub = @{ - ApiKey = 'C:\Support\Important\GithubAPI.txt' - FromFile = $true - UserName = 'EvotecIT' - #RepositoryName = 'PSPublishModule' # not required, uses project name - } - Documentation = @{ - Path = 'Docs' - PathReadme = 'Docs\Readme.md' - } - Style = @{ - PSD1 = 'Minimal' # Native - } - Signing = @{ - CertificateThumbprint = '36A8A2D0E227D81A2D3B60DCE0CFCF23BEFC343B' - } + $ConfigurationFormat = [ordered] @{ + RemoveComments = $true + RemoveEmptyLines = $true + + PlaceOpenBraceEnable = $true + PlaceOpenBraceOnSameLine = $true + PlaceOpenBraceNewLineAfter = $true + PlaceOpenBraceIgnoreOneLineBlock = $false + + PlaceCloseBraceEnable = $true + PlaceCloseBraceNewLineAfter = $true + PlaceCloseBraceIgnoreOneLineBlock = $false + PlaceCloseBraceNoEmptyLineBefore = $true + + UseConsistentIndentationEnable = $true + UseConsistentIndentationKind = 'space' + UseConsistentIndentationPipelineIndentation = 'IncreaseIndentationAfterEveryPipeline' + UseConsistentIndentationIndentationSize = 4 + + UseConsistentWhitespaceEnable = $true + UseConsistentWhitespaceCheckInnerBrace = $true + UseConsistentWhitespaceCheckOpenBrace = $true + UseConsistentWhitespaceCheckOpenParen = $true + UseConsistentWhitespaceCheckOperator = $true + UseConsistentWhitespaceCheckPipe = $true + UseConsistentWhitespaceCheckSeparator = $true + + AlignAssignmentStatementEnable = $true + AlignAssignmentStatementCheckHashtable = $true + + UseCorrectCasingEnable = $true } - Steps = @{ - BuildModule = @{ # requires Enable to be on to process all of that - Enable = $true - DeleteBefore = $false - Merge = $true - MergeMissing = $true - SignMerged = $true - Releases = $true - ReleasesUnpacked = $false - RefreshPSD1Only = $false - } - BuildDocumentation = @{ - Enable = $true # enables documentation processing - StartClean = $true # always starts clean - UpdateWhenNew = $true # always updates right after new - } - ImportModules = @{ - Self = $true - RequiredModules = $false - Verbose = $false - } - PublishModule = @{ # requires Enable to be on to process all of that - Enabled = $false - Prerelease = '' - RequireForce = $false - GitHub = $false - } - } -} + # format PSD1 and PSM1 files when merging into a single file + # enable formatting is not required as Configuration is provided + New-ConfigurationFormat -ApplyTo 'OnMergePSM1', 'OnMergePSD1' -Sort None @ConfigurationFormat + # format PSD1 and PSM1 files within the module + # enable formatting is required to make sure that formatting is applied (with default settings) + New-ConfigurationFormat -ApplyTo 'DefaultPSD1', 'DefaultPSM1' -EnableFormatting -Sort None + # when creating PSD1 use special style without comments and with only required parameters + New-ConfigurationFormat -ApplyTo 'DefaultPSD1', 'OnMergePSD1' -PSD1Style 'Minimal' + # configuration for documentation, at the same time it enables documentation processing + New-ConfigurationDocumentation -Enable:$false -StartClean -UpdateWhenNew -PathReadme 'Docs\Readme.md' -Path 'Docs' -New-PrepareModule -Configuration $Configuration \ No newline at end of file + New-ConfigurationImportModule -ImportSelf + + New-ConfigurationBuild -Enable:$true -SignModule -MergeModuleOnBuild -MergeFunctionsFromApprovedModules -CertificateThumbprint '483292C9E317AA13B07BB7A96AE9D1A5ED9E7703' + + # New-ConfigurationTest -TestsPath "$PSScriptRoot\..\Tests" -Enable + + New-ConfigurationArtefact -Type Unpacked -Enable -Path "$PSScriptRoot\..\Artefacts\Unpacked" -AddRequiredModules + New-ConfigurationArtefact -Type Packed -Enable -Path "$PSScriptRoot\..\Artefacts\Packed" -ArtefactName '.v.zip' + + # options for publishing to github/psgallery + #New-ConfigurationPublish -Type PowerShellGallery -FilePath 'C:\Support\Important\PowerShellGalleryAPI.txt' -Enabled:$true + #New-ConfigurationPublish -Type GitHub -FilePath 'C:\Support\Important\GitHubAPI.txt' -UserName 'EvotecIT' -Enabled:$true +} -ExitCode \ No newline at end of file