Skip to content

Commit 624f1e9

Browse files
Chocolatey auto deploy
1 parent a5b6eb9 commit 624f1e9

10 files changed

Lines changed: 93 additions & 91 deletions

File tree

.github/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ The online version of [PowerShell Get-Help documentation](../Documentation/Power
134134

135135
I have also published a series of articles about the DSInternals module on [my blog](https://www.dsinternals.com/en/). Here are a few of them:
136136

137+
- [Juicing ntds.dit Files to the Last Drop](https://specterops.io/blog/2025/08/14/juicing-ntds-dit-files-last-drop-dsinternals-powershell-active-directory-offline-attacks/)
137138
- [New Offline Capabilities in DSInternals 4.11](https://www.dsinternals.com/en/dsinternals-v4.11/)
138139
- [Cross-Forest Duplicate Password Discovery](https://www.dsinternals.com/en/cross-forest-duplicate-password-discovery/)
139140
- [CQLabs – Extracting Roamed Private Keys from Active Directory](https://cqureacademy.com/blog/extracting-roamed-private-keys)

.github/workflows/autobuild.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ jobs:
3131
- name: Setup .NET
3232
uses: actions/setup-dotnet@v4
3333
with:
34-
# .NET SDK 9 is used for build. Platform-specific IJW hosts from .NET SDK 8 are used when building C++/CLI projects.
35-
dotnet-version: |
34+
# .NET SDK 9 is used for build. Platform-specific IJW hosts from .NET SDK 8 are used when building C++/CLI projects.
35+
dotnet-version: |
3636
8.0.x
3737
9.0.x
3838
cache: true
@@ -58,7 +58,7 @@ jobs:
5858
shell: powershell
5959
working-directory: Build/bin/DSInternals.PowerShell/Debug
6060
run: New-FileCatalog -CatalogVersion 2 -Path DSInternals -CatalogFilePath .\DSInternals\DSInternals.cat
61-
61+
6262
- name: Create Managed NuGet Packages
6363
working-directory: Src
6464
run: |
@@ -113,9 +113,20 @@ jobs:
113113
with:
114114
name: DSInternals_v${{ steps.get-module-version.outputs.version }}_debug
115115
path: Build/bin/DSInternals.PowerShell/Debug
116-
116+
117117
- name: Upload NuGet Packages as Artifacts
118118
uses: actions/upload-artifact@v4
119119
with:
120120
name: NuGet_v${{ steps.get-module-version.outputs.version }}_debug
121121
path: Build/package/debug/*nupkg
122+
123+
- name: Create Chocolatey Package
124+
shell: pwsh
125+
run: |
126+
choco pack Src/DSInternals.PowerShell/Chocolatey/dsinternals-psmodule.nuspec --version=${{ steps.get-module-version.outputs.version }} --output-directory=Build/package/Chocolatey --execution-timeout=60 --confirm configuration=Debug
127+
128+
- name: Upload Chocolatey Package as Artifact
129+
uses: actions/upload-artifact@v4
130+
with:
131+
name: Chocolatey_v${{ steps.get-module-version.outputs.version }}_debug
132+
path: Build/package/Chocolatey/*.nupkg

.github/workflows/release.yml

Lines changed: 57 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ jobs:
5050
timeout-minutes: 10
5151
outputs:
5252
nuget-artifact-id: ${{ steps.upload-nuget.outputs.artifact-id }}
53+
chocolatey-artifact-id: ${{ steps.upload-chocolatey.outputs.artifact-id }}
5354
powershell-artifact-id: ${{ steps.upload-powershell.outputs.artifact-id }}
5455
powershell-module-version: ${{ steps.get-module-info.outputs.version }}
5556
powershell-module-release-notes: ${{ steps.get-module-info.outputs.release-notes }}
@@ -79,12 +80,12 @@ jobs:
7980
uses: microsoft/setup-msbuild@v2
8081
with:
8182
msbuild-architecture: x64 # default is x86
82-
83+
8384
- name: Setup .NET
8485
uses: actions/setup-dotnet@v4
8586
with:
86-
# .NET SDK 9 is used for build. Platform-specific IJW hosts from .NET SDK 8 are used when building C++/CLI projects.
87-
dotnet-version: |
87+
# .NET SDK 9 is used for build. Platform-specific IJW hosts from .NET SDK 8 are used when building C++/CLI projects.
88+
dotnet-version: |
8889
8.0.x
8990
9.0.x
9091
cache: true
@@ -127,7 +128,7 @@ jobs:
127128
client-id: ${{ secrets.SIGNING_CLIENT_ID }}
128129
tenant-id: ${{ secrets.SIGNING_TENANT_ID }}
129130
allow-no-subscriptions: true
130-
131+
131132
- name: Sign Binaries and Scripts
132133
shell: cmd
133134
if: ${{ inputs.certificate_sign }}
@@ -184,12 +185,12 @@ jobs:
184185
shell: powershell
185186
working-directory: Build/bin/DSInternals.PowerShell/Release
186187
run: New-FileCatalog -CatalogVersion 2 -Path DSInternals -CatalogFilePath .\DSInternals\DSInternals.cat
187-
188+
188189
- name: Create Managed NuGet Packages
189190
working-directory: Src
190191
run: |
191192
dotnet pack DSInternals.DotNetSdk.slnf --configuration Release --no-build
192-
193+
193194
- name: Create Mixed NuGet Package
194195
working-directory: Src
195196
run: |
@@ -218,27 +219,54 @@ jobs:
218219
[hashtable] $manifest = Import-PowerShellDataFile -Path ./Src/DSInternals.PowerShell/DSInternals.psd1
219220
[string] $version = $manifest.ModuleVersion
220221
[string] $releaseNotes = $manifest.PrivateData.PSData.ReleaseNotes
221-
222+
222223
echo "version=$version" >> $env:GITHUB_OUTPUT
223224
224225
echo 'release-notes<<EOF' >> $env:GITHUB_OUTPUT
225226
echo $releaseNotes >> $env:GITHUB_OUTPUT
226227
echo 'EOF' >> $env:GITHUB_OUTPUT
227228
229+
- name: Create Chocolatey Package
230+
shell: pwsh
231+
run: |
232+
choco pack Src/DSInternals.PowerShell/Chocolatey/dsinternals-psmodule.nuspec --version=${{ steps.get-module-info.outputs.version }} --output-directory=Build/package/Chocolatey --execution-timeout=60 --confirm configuration=Release
233+
234+
- name: Sign Chocolatey Package
235+
shell: cmd
236+
if: ${{ inputs.certificate_sign }}
237+
run: >
238+
sign code azure-key-vault
239+
*.nupkg
240+
--base-directory "${{ github.workspace }}/Build/package/Chocolatey"
241+
--azure-key-vault-url "${{ secrets.SIGNING_KEY_VAULT_URL }}"
242+
--azure-key-vault-certificate "${{ secrets.SIGNING_KEY_VAULT_CERTIFICATE }}"
243+
--azure-credential-type azure-cli
244+
--file-digest SHA256
245+
--timestamp-digest SHA256
246+
--timestamp-url "http://timestamp.acs.microsoft.com"
247+
--verbosity Information
248+
228249
- name: Upload PowerShell Module as Artifact
229250
uses: actions/upload-artifact@v4
230251
id: upload-powershell
231252
with:
232253
name: DSInternals_v${{ steps.get-module-info.outputs.version }}
233254
path: Build/bin/DSInternals.PowerShell/Release
234-
255+
235256
- name: Upload NuGet Packages as Artifacts
236257
uses: actions/upload-artifact@v4
237258
id: upload-nuget
238259
with:
239260
name: NuGet_v${{ steps.get-module-info.outputs.version }}
240261
path: Build/package/release/*nupkg
241262

263+
- name: Upload Chocolatey Package as Artifact
264+
uses: actions/upload-artifact@v4
265+
id: upload-chocolatey
266+
with:
267+
name: Chocolatey_v${{ steps.get-module-info.outputs.version }}
268+
path: Build/package/Chocolatey/*.nupkg
269+
242270
- name: Run PowerShell Desktop Tests
243271
working-directory: Scripts
244272
shell: powershell
@@ -301,7 +329,7 @@ jobs:
301329
steps:
302330
- name: Checkout Repository
303331
uses: actions/checkout@v4
304-
332+
305333
- name: Download PowerShell Module
306334
uses: actions/download-artifact@v5
307335
with:
@@ -321,7 +349,7 @@ jobs:
321349
run: |
322350
@'
323351
### Notable Changes
324-
352+
325353
${{ needs.build.outputs.powershell-module-release-notes }}
326354
327355
See the [Changelog](https://github.com/MichaelGrafnetter/DSInternals/blob/master/Documentation/CHANGELOG.md) for a more detailed list of new features.
@@ -330,11 +358,28 @@ jobs:
330358
331359
- The module is available in the [PowerShell Gallery](https://www.powershellgallery.com/packages/DSInternals).
332360
- As an alternative, the attached `DSInternals_v${{ needs.build.outputs.powershell-module-version }}.zip` file can be used for [offline module installation](https://github.com/MichaelGrafnetter/DSInternals#offline-module-distribution).
333-
361+
- The module is also available as a [Chocolatey package](https://community.chocolatey.org/packages/dsinternals-psmodule).
362+
334363
### NuGet Packages
335364
336365
Official binary packages are available in the [NuGet Gallery](https://www.nuget.org/profiles/DSInternals).
337366
'@ > release-notes.md
338367
gh release create v${{ needs.build.outputs.powershell-module-version }} ./*.zip --draft --latest --title "DSInternals PowerShell Module ${{ needs.build.outputs.powershell-module-version }}" --notes-file release-notes.md
339368
340-
# TODO: chocolatey
369+
chocolatey:
370+
name: 'Publish to Chocolatey Gallery'
371+
if: ${{ inputs.publish_chocolatey }}
372+
runs-on: windows-2025
373+
needs: build
374+
steps:
375+
- name: Download Chocolatey Package
376+
uses: actions/download-artifact@v5
377+
with:
378+
artifact-ids: ${{ needs.build.outputs.chocolatey-artifact-id }}
379+
380+
- name: Publish Chocolatey Package
381+
shell: pwsh
382+
env:
383+
CHOCOLATEY_APIKEY: ${{ secrets.CHOCOLATEY_APIKEY }}
384+
run: |
385+
choco push *.nupkg --source='https://push.chocolatey.org/' --api-key=$env:CHOCOLATEY_APIKEY

Scripts/Pack-Chocolatey.ps1

Lines changed: 0 additions & 25 deletions
This file was deleted.

Scripts/Publish-Chocolatey.ps1

Lines changed: 0 additions & 20 deletions
This file was deleted.

Src/DSInternals.PowerShell/Chocolatey/dsinternals-psmodule.nuspec

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
44
<metadata>
55
<id>DSInternals-PSModule</id>
6-
<version>6.1.1</version>
6+
<version>$version$</version>
77
<packageSourceUrl>https://github.com/MichaelGrafnetter/DSInternals/tree/master/Src/DSInternals.PowerShell/Chocolatey</packageSourceUrl>
88
<owners>MichaelGrafnetter</owners>
99
<title>DSInternals PowerShell Module</title>
@@ -40,17 +40,16 @@ Features exposed through these tools are not supported by Microsoft. Improper us
4040
* Resolved issues with parsing LAPS passwords and key credentials.
4141
</releaseNotes>
4242
<dependencies>
43-
<!-- Windows Management Framework 3+. For OS prior to Windows 8 and Windows Server 2012. -->
44-
<dependency id="powershell" version="3.0.20121027" />
43+
<!-- Windows Management Framework 5.1+. For OS prior to Windows 10 and Windows Server 2016. -->
44+
<dependency id="powershell" version="5.1.14409.1005" />
4545
<!-- Universal C Runtime. For RTM OS prior to Windows 10 and Windows Server 2016. -->
4646
<dependency id="kb2999226" version="1.0.20181019" />
47-
<!-- .NET Framework 4.7.2+. For RTM OS prior to Windows 10 1703 and Windows Server 1709. -->
48-
<dependency id="dotnetfx" version="4.7.2.0" />
47+
<!-- .NET Framework 4.8+. For RTM OS prior to Windows 10 1903 and Windows Server 1903. -->
48+
<dependency id="dotnetfx" version="4.8.0.20220524" />
4949
</dependencies>
5050
</metadata>
5151
<files>
5252
<file src="tools\**" target="tools" />
53-
<file src="..\..\..\Build\bin\DSInternals.PowerShell\Release\DSInternals\**" target="DSInternals" />
54-
<file src="..\..\..\Build\bin\DSInternals.PowerShell\Release\DSInternals.cat" target="tools\DSInternals.cat" />
53+
<file src="..\..\..\Build\bin\DSInternals.PowerShell\$configuration$\DSInternals\**" target="DSInternals" />
5554
</files>
5655
</package>
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
VERIFICATION
22

33
This is the official DSInternals PowerShell Module Chocolatey package.
4-
54
The package is self-contained and contains the same files as the GitHub ZIP release (https://github.com/MichaelGrafnetter/DSInternals/releases).
65

7-
File integrity can be checked against the catalog file using the following PowerShell 5 command:
8-
9-
Test-FileCatalog -CatalogFilePath tools\DSInternals.cat -Path DSInternals -Detailed
10-
11-
Note that the catalog file is not digitally signed (for now).
6+
All binary and script files should be digitally signed.
7+
Module integrity can be checked using the bundled "Integrity.Tests.ps1" script.

Src/DSInternals.PowerShell/Chocolatey/tools/chocolateyinstall.ps1

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@ $ErrorActionPreference = 'Stop'
33

44
# Check PowerShell Version
55
# Note: The #requires statement is not used in order to provide a custom message.
6-
if ($PSVersionTable.PSVersion -lt [Version]'3.0')
6+
if ($PSVersionTable.PSVersion -lt [Version]'5.1')
77
{
8-
throw 'The minimum required version of PowerShell is 3. Please upgrade by running the "choco install powershell" command first.'
8+
throw 'The minimum required version of PowerShell is 5.1. Please upgrade by running the "choco install powershell" command first.'
99
}
1010

1111
# Copy Files
12-
$toolsDir = Split-Path -Parent ($MyInvocation.MyCommand.Definition)
13-
$sourceDir = Join-Path -Path $toolsDir -ChildPath '..\DSInternals' -Resolve
14-
$destinationDir = Join-Path -Path $PSHOME -ChildPath 'Modules\DSInternals'
15-
robocopy $sourceDir $destinationDir /MIR /MOVE /NJS /NJH /NDL /NFL /NS /NP
12+
[string] $rootDir = Split-Path -Parent -Path $PSScriptRoot
13+
[string] $sourceDir = Join-Path -Path $rootDir -ChildPath 'DSInternals' -Resolve
14+
[string] $destinationDir = Join-Path -Path $PSHOME -ChildPath 'Modules\DSInternals'
15+
robocopy.exe $sourceDir $destinationDir /MIR /MOVE /NJS /NJH /NDL /NFL /NS /NP
1616

1717
# Cleanup
1818
Remove-Item -Path $sourceDir -Recurse -Force -ErrorAction SilentlyContinue
1919

2020
# Create Start Menu Link
21-
$psPath = (Get-Command -Name 'powershell.exe').Path
22-
$psArguments = '-NoExit -Command "& { Import-Module -Name DSInternals; Get-Help -Name about_DSInternals }"'
23-
$shortcutPath = Join-Path -Path $env:ProgramData -ChildPath 'Microsoft\Windows\Start Menu\Programs\DSInternals PowerShell Module.lnk'
21+
[string] $psPath = (Get-Command -Name 'powershell.exe').Path
22+
[string] $psArguments = '-NoExit -Command "& { Import-Module -Name DSInternals; Get-Help -Name about_DSInternals }"'
23+
[string] $shortcutPath = Join-Path -Path $env:ProgramData -ChildPath 'Microsoft\Windows\Start Menu\Programs\DSInternals PowerShell Module.lnk'
2424
Install-ChocolateyShortcut -ShortcutFilePath $shortcutPath -TargetPath $psPath -Arguments $psArguments -WorkingDirectory "$env:SystemDrive\"
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
$ErrorActionPreference = 'Stop'
22

33
# Remove Module Files
4-
$destinationDir = Join-Path -Path $PSHOME -ChildPath 'Modules\DSInternals'
4+
[string] $destinationDir = Join-Path -Path $PSHOME -ChildPath 'Modules\DSInternals'
55
Remove-Item -Path $destinationDir -Recurse -Force -ErrorAction SilentlyContinue
66

77
# Remove Start Menu Link
8-
$shortcutPath = Join-Path -Path $env:ProgramData -ChildPath 'Microsoft\Windows\Start Menu\Programs\DSInternals PowerShell Module.lnk'
8+
[string] $shortcutPath = Join-Path -Path $env:ProgramData -ChildPath 'Microsoft\Windows\Start Menu\Programs\DSInternals PowerShell Module.lnk'
99
Remove-Item -Path $shortcutPath -Force -ErrorAction SilentlyContinue

Src/DSInternals.PowerShell/Tests/Chocolatey.Tests.ps1

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#>
55
#Requires -Version 5.1
66
#Requires -Modules @{ ModuleName = 'Pester'; ModuleVersion = '5.0' }
7-
7+
88
Describe 'Chocolatey Package' {
99
BeforeAll {
1010
# Get the manifest paths
@@ -20,11 +20,6 @@ Describe 'Chocolatey Package' {
2020
$chocolateySpec.package.metadata.description.Length | Should -BeLessOrEqual 4000 -Because 'package upload would fail otherwise.'
2121
}
2222

23-
# Now compare the shared values
24-
It 'has the same version as the module' {
25-
$chocolateySpec.package.metadata.version | Should -Be $moduleManifest.ModuleVersion
26-
}
27-
2823
It 'has the same release notes as the module' {
2924
# Remove line breaks and backticks (markdown code sections) from the release notes.
3025
[string] $normalizedChocolateyReleaseNotes = $chocolateySpec.package.metadata.releaseNotes.Replace("`r`n","`n").Replace('`','').Trim()

0 commit comments

Comments
 (0)