From 678ff90db737166e635430b7124775cb496b4b4e Mon Sep 17 00:00:00 2001 From: Raimund Andree Date: Sun, 4 Oct 2026 14:45:05 +0200 Subject: [PATCH] feat!: prepare version 5.0.0 with a valid module manifest - Require Windows PowerShell 5.1 or PowerShell 7 (PowerShellVersion 5.1, which CompatiblePSEditions needs) and .NET Framework 4.5.2, and use RootModule instead of the deprecated ModuleToProcess. Before, Test-ModuleManifest, and with it Publish-Module, failed. - Export exactly the 36 cmdlets: remove Show-NTFSSimpleAccess, which no longer exists, and the duplicate inheritance cmdlets. - Keep -PassThur, the name in 4.2.6 and earlier, as an alias of Remove-Item2 -PassThru, deprecated in the changelog. - Set version 5.0.0 in the manifest, in NTFSSecurity, Security2, and PrivilegeControl, and in a new 5.0.0 section of CHANGELOG.md. - Tests/Manifest.Tests.ps1 and Tests/Remove-Item2.Tests.ps1 guard the manifest, the versions, and the alias. BREAKING CHANGE: the module requires Windows PowerShell 5.1 or PowerShell 7; the manifest no longer claims PowerShell 2.0. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: AI Assistant --- CHANGELOG.md | 24 +++++-- Docs/Cmdlets/Remove-Item2.md | 4 +- NTFSSecurity/ItemCmdlets/RemoveItem2.cs | 2 + NTFSSecurity/NTFSSecurity.psd1 | 13 ++-- NTFSSecurity/Properties/AssemblyInfo.cs | 4 +- NTFSSecurity/en-US/NTFSSecurity.dll-Help.xml | 8 +-- PrivilegeControl/Properties/AssemblyInfo.cs | 4 +- Security2/Properties/AssemblyInfo.cs | 4 +- Tests/Manifest.Tests.ps1 | 73 ++++++++++++++++++++ Tests/Remove-Item2.Tests.ps1 | 35 ++++++++++ 10 files changed, 145 insertions(+), 26 deletions(-) create mode 100644 Tests/Manifest.Tests.ps1 create mode 100644 Tests/Remove-Item2.Tests.ps1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 22a1a5e..5dac731 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,12 +8,18 @@ The format is based on ## [Unreleased] +## [5.0.0] - 2026-10-04 + ### Changed -- **Breaking:** rename the `-PassThur` parameter of `Remove-Item2` to - `-PassThru` ([#64](https://github.com/raandree/NTFSSecurity/pull/64)) -- Declare support for Windows PowerShell and PowerShell 7 in the module - manifest ([#61](https://github.com/raandree/NTFSSecurity/issues/61)) +- **Breaking:** require Windows PowerShell 5.1 or PowerShell 7, and declare + support for both editions in the module manifest + ([#61](https://github.com/raandree/NTFSSecurity/issues/61)); the manifest + declared PowerShell 2.0 and .NET Framework 3.5, although the module needs + .NET Framework 4.5.2 +- Rename the `-PassThur` parameter of `Remove-Item2` to `-PassThru`; + `-PassThur` still works as an alias + ([#64](https://github.com/raandree/NTFSSecurity/pull/64)) - Document every cmdlet with synopsis, description, parameters, examples, inputs, outputs, and notes, checked against the source code - Rewrite the home, concepts, examples, and contributor pages to match the @@ -21,6 +27,10 @@ The format is based on - Move the version history and the installation instructions from the wiki into the documentation, and add the missing notes for 4.2.5 and 4.2.6 +### Deprecated + +- Deprecate the `-PassThur` alias of `Remove-Item2`; use `-PassThru` + ### Fixed - Fix `Get-Help`, which showed only the syntax: ship the help file @@ -29,5 +39,9 @@ The format is based on `NTFSSecurity-Help.xml` - Fix documentation examples that did not work, such as restoring permissions from a CSV file and filtering entries by account +- Remove `Show-NTFSSimpleAccess`, which no longer exists, and duplicate + entries from the cmdlets that the module manifest exports and the + PowerShell Gallery lists -[Unreleased]: https://github.com/raandree/NTFSSecurity/compare/4.2.6...HEAD +[Unreleased]: https://github.com/raandree/NTFSSecurity/compare/5.0.0...HEAD +[5.0.0]: https://github.com/raandree/NTFSSecurity/compare/4.2.6...5.0.0 diff --git a/Docs/Cmdlets/Remove-Item2.md b/Docs/Cmdlets/Remove-Item2.md index 8cde166..40d1bad 100644 --- a/Docs/Cmdlets/Remove-Item2.md +++ b/Docs/Cmdlets/Remove-Item2.md @@ -95,12 +95,12 @@ Accept wildcard characters: False ### -PassThru -Indicates that the cmdlet returns an object for each item that it deleted. By default, the cmdlet produces no output. The object describes a path that no longer exists, so use it for logging rather than for further file operations. In NTFSSecurity 4.2.6 and earlier, this parameter is spelled `-PassThur`. +Indicates that the cmdlet returns an object for each item that it deleted. By default, the cmdlet produces no output. The object describes a path that no longer exists, so use it for logging rather than for further file operations. `-PassThur`, the name of this parameter in NTFSSecurity 4.2.6 and earlier, still works as an alias. ```yaml Type: SwitchParameter Parameter Sets: (All) -Aliases: +Aliases: PassThur Required: False Position: Named diff --git a/NTFSSecurity/ItemCmdlets/RemoveItem2.cs b/NTFSSecurity/ItemCmdlets/RemoveItem2.cs index 8c5c80a..0d3a135 100644 --- a/NTFSSecurity/ItemCmdlets/RemoveItem2.cs +++ b/NTFSSecurity/ItemCmdlets/RemoveItem2.cs @@ -39,7 +39,9 @@ namespace NTFSSecurity set { recurse = value; } } + // -PassThur is the parameter name in 4.2.6 and earlier. [Parameter] + [Alias("PassThur")] public SwitchParameter PassThru { get { return passThru; } diff --git a/NTFSSecurity/NTFSSecurity.psd1 b/NTFSSecurity/NTFSSecurity.psd1 index aa097ad..f9ce836 100644 --- a/NTFSSecurity/NTFSSecurity.psd1 +++ b/NTFSSecurity/NTFSSecurity.psd1 @@ -1,7 +1,7 @@ @{ - ModuleToProcess = 'NTFSSecurity.psm1' + RootModule = 'NTFSSecurity.psm1' - ModuleVersion = '4.2.5' + ModuleVersion = '5.0.0' GUID = 'cd303a6c-f405-4dcb-b1ce-fbc2c52264e9' @@ -13,11 +13,11 @@ Description = 'Windows PowerShell Module for managing file and folder security on NTFS volumes' - PowerShellVersion = '2.0' + PowerShellVersion = '5.1' CompatiblePSEditions = 'Core', 'Desktop' - DotNetFrameworkVersion = '3.5' + DotNetFrameworkVersion = '4.5.2' ScriptsToProcess = @('NTFSSecurity.Init.ps1') @@ -31,19 +31,14 @@ CmdletsToExport = 'Add-NTFSAccess', 'Clear-NTFSAccess', - 'Disable-NTFSAccessInheritance', - 'Enable-NTFSAccessInheritance', 'Get-NTFSAccess', 'Get-NTFSEffectiveAccess', 'Get-NTFSOrphanedAccess', 'Get-NTFSSimpleAccess', 'Remove-NTFSAccess', - 'Show-NTFSSimpleAccess', #---------------------------------------------- 'Add-NTFSAudit', 'Clear-NTFSAudit', - 'Disable-NTFSAuditInheritance', - 'Enable-NTFSAuditInheritance', 'Get-NTFSAudit', 'Get-NTFSOrphanedAudit', 'Remove-NTFSAudit', diff --git a/NTFSSecurity/Properties/AssemblyInfo.cs b/NTFSSecurity/Properties/AssemblyInfo.cs index 104c43d..71e8c5b 100644 --- a/NTFSSecurity/Properties/AssemblyInfo.cs +++ b/NTFSSecurity/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("4.2.1.0")] -[assembly: AssemblyFileVersion("4.2.1.0")] +[assembly: AssemblyVersion("5.0.0.0")] +[assembly: AssemblyFileVersion("5.0.0.0")] diff --git a/NTFSSecurity/en-US/NTFSSecurity.dll-Help.xml b/NTFSSecurity/en-US/NTFSSecurity.dll-Help.xml index ecd6730..039bfe6 100644 --- a/NTFSSecurity/en-US/NTFSSecurity.dll-Help.xml +++ b/NTFSSecurity/en-US/NTFSSecurity.dll-Help.xml @@ -7400,10 +7400,10 @@ PS C:\Data> Get-NTFSSecurityDescriptor False - + PassThru - Indicates that the cmdlet returns an object for each item that it deleted. By default, the cmdlet produces no output. The object describes a path that no longer exists, so use it for logging rather than for further file operations. In NTFSSecurity 4.2.6 and earlier, this parameter is spelled `-PassThur`. + Indicates that the cmdlet returns an object for each item that it deleted. By default, the cmdlet produces no output. The object describes a path that no longer exists, so use it for logging rather than for further file operations. `-PassThur`, the name of this parameter in NTFSSecurity 4.2.6 and earlier, still works as an alias. SwitchParameter @@ -7460,10 +7460,10 @@ PS C:\Data> Get-NTFSSecurityDescriptor False - + PassThru - Indicates that the cmdlet returns an object for each item that it deleted. By default, the cmdlet produces no output. The object describes a path that no longer exists, so use it for logging rather than for further file operations. In NTFSSecurity 4.2.6 and earlier, this parameter is spelled `-PassThur`. + Indicates that the cmdlet returns an object for each item that it deleted. By default, the cmdlet produces no output. The object describes a path that no longer exists, so use it for logging rather than for further file operations. `-PassThur`, the name of this parameter in NTFSSecurity 4.2.6 and earlier, still works as an alias. SwitchParameter diff --git a/PrivilegeControl/Properties/AssemblyInfo.cs b/PrivilegeControl/Properties/AssemblyInfo.cs index d86c591..03335c3 100644 --- a/PrivilegeControl/Properties/AssemblyInfo.cs +++ b/PrivilegeControl/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("5.0.0.0")] +[assembly: AssemblyFileVersion("5.0.0.0")] diff --git a/Security2/Properties/AssemblyInfo.cs b/Security2/Properties/AssemblyInfo.cs index 6144a7c..89a37d6 100644 --- a/Security2/Properties/AssemblyInfo.cs +++ b/Security2/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("3.2.3.0")] -[assembly: AssemblyFileVersion("3.2.3.0")] +[assembly: AssemblyVersion("5.0.0.0")] +[assembly: AssemblyFileVersion("5.0.0.0")] diff --git a/Tests/Manifest.Tests.ps1 b/Tests/Manifest.Tests.ps1 new file mode 100644 index 0000000..7f33576 --- /dev/null +++ b/Tests/Manifest.Tests.ps1 @@ -0,0 +1,73 @@ +<# + Tests the module manifest of the module built in NTFSSecurity\bin\Release: it passes Test-ModuleManifest, + exports exactly the cmdlets of the module, and carries the same version as the assemblies and CHANGELOG.md. +#> +[Diagnostics.CodeAnalysis.SuppressMessageAttribute( + 'PSUseDeclaredVarsMoreThanAssignments', '', Justification = 'Pester shares variables between blocks.' +)] +param () + +BeforeDiscovery { + # The first-party assemblies of the module carry the module version; ProcessPrivileges is a vendored library. + $versionedAssemblies = 'NTFSSecurity', 'Security2', 'PrivilegeControl' +} + +Describe 'Module manifest of NTFSSecurity' { + BeforeAll { + $manifestPath = Join-Path -Path $PSScriptRoot -ChildPath '..\NTFSSecurity\bin\Release\NTFSSecurity.psd1' + $manifest = Import-PowerShellDataFile -Path $manifestPath + $module = Import-Module -Name $manifestPath -Force -PassThru -ErrorAction Stop | + Where-Object -Property Name -EQ -Value 'NTFSSecurity' + } + + AfterAll { + Remove-Module -Name NTFSSecurity -Force -ErrorAction SilentlyContinue + } + + It 'Should pass Test-ModuleManifest without errors or warnings' { + $testParameters = @{ + Path = $manifestPath + ErrorVariable = 'manifestErrors' + WarningVariable = 'manifestWarnings' + ErrorAction = 'SilentlyContinue' + WarningAction = 'SilentlyContinue' + } + $null = Test-ModuleManifest @testParameters + + @($manifestErrors) + @($manifestWarnings) | ForEach-Object -Process { "$_" } | Should -BeNullOrEmpty + } + + It 'Should list each cmdlet only once in CmdletsToExport' { + $duplicates = $manifest.CmdletsToExport | Group-Object | Where-Object -Property Count -GT -Value 1 + + $duplicates.Name | Should -BeNullOrEmpty + } + + It 'Should list only cmdlets of the module in CmdletsToExport' { + $manifest.CmdletsToExport | Where-Object -FilterScript { -not $module.ExportedCmdlets.ContainsKey($_) } | + Should -BeNullOrEmpty + } + + It 'Should export exactly 36 cmdlets' { + @($manifest.CmdletsToExport) | Should -HaveCount 36 + $module.ExportedCmdlets.Keys | Should -HaveCount 36 + } + + Context 'Version' { + It 'Should give <_>.dll the module version' -ForEach $versionedAssemblies { + $assemblyPath = Join-Path -Path $module.ModuleBase -ChildPath "$_.dll" + $assemblyVersion = [Reflection.AssemblyName]::GetAssemblyName($assemblyPath).Version + $fileVersion = [version] (Get-Item -LiteralPath $assemblyPath).VersionInfo.FileVersion + + $assemblyVersion.ToString(3) | Should -BeExactly $manifest.ModuleVersion + $fileVersion.ToString(3) | Should -BeExactly $manifest.ModuleVersion + } + + It 'Should describe the module version in the latest section of CHANGELOG.md' { + $changelog = Get-Content -LiteralPath (Join-Path -Path $PSScriptRoot -ChildPath '..\CHANGELOG.md') -Raw + $latestVersion = [regex]::Match($changelog, '(?m)^## \[(?\d+\.\d+\.\d+)\]').Groups['Version'].Value + + $latestVersion | Should -BeExactly $manifest.ModuleVersion + } + } +} diff --git a/Tests/Remove-Item2.Tests.ps1 b/Tests/Remove-Item2.Tests.ps1 new file mode 100644 index 0000000..853c545 --- /dev/null +++ b/Tests/Remove-Item2.Tests.ps1 @@ -0,0 +1,35 @@ +<# + Tests Remove-Item2 of the module built in NTFSSecurity\bin\Release. +#> +[Diagnostics.CodeAnalysis.SuppressMessageAttribute( + 'PSUseDeclaredVarsMoreThanAssignments', '', Justification = 'Pester shares variables between blocks.' +)] +param () + +Describe 'Remove-Item2' { + BeforeAll { + $modulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\NTFSSecurity\bin\Release\NTFSSecurity.psd1' + Import-Module -Name $modulePath -Force -ErrorAction Stop + } + + AfterAll { + Remove-Module -Name NTFSSecurity -Force -ErrorAction SilentlyContinue + } + + Context 'When called with -PassThur, the parameter name in 4.2.6 and earlier' { + BeforeAll { + $path = Join-Path -Path $TestDrive -ChildPath 'PassThur.txt' + Set-Content -LiteralPath $path -Value 'Remove-Item2 test' + + $removedItem = Remove-Item2 -Path $path -PassThur + } + + It 'Should delete the file' { + $path | Should -Not -Exist + } + + It 'Should return the deleted file, like -PassThru' { + $removedItem.Name | Should -BeExactly 'PassThur.txt' + } + } +}