Skip to content

Commit 37e2841

Browse files
authored
Updated to latest Sampler files (#211)
1 parent d99f804 commit 37e2841

File tree

4 files changed

+105
-66
lines changed

4 files changed

+105
-66
lines changed

CHANGELOG.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
### Added
99

1010
- AddsDomainController:
11-
- add UnprotectFromAccidentalDeletion to allow dc promote if an existing AD computer account is protected
12-
- AllowPasswordReplication and DenyPasswordReplication Variables for RODCs
11+
- add UnprotectFromAccidentalDeletion to allow dc promote if an existing AD computer account is protected
12+
- AllowPasswordReplication and DenyPasswordReplication Variables for RODCs
1313
- AzureConnectedMachine:
14-
- Composite to install and configure the Azure Connected Machine Agent
14+
- Composite to install and configure the Azure Connected Machine Agent
1515
- DhcpServerAuthorization:
16-
- new resource to authorize DHCP server in AD
16+
- new resource to authorize DHCP server in AD
1717
- FailoverCluster:
18-
- add Networks support
19-
- add installation of required Windows Features
20-
- update documentation
18+
- add Networks support
19+
- add installation of required Windows Features
20+
- update documentation
2121
- HyperVReplica
22-
- new resource to configure replication of Hyper-V virtual machines
22+
- new resource to configure replication of Hyper-V virtual machines
2323
- HyperVState
24-
- new resource to control state parameters of Hyper-V virtual machines
24+
- new resource to control state parameters of Hyper-V virtual machines
2525

2626
### Changed
2727

2828
- Fixed Typo in AddsDomainController documentation
2929
- DHCPServer:
30-
- fix EnableSecurityGroups if resource is not running on a domain controller
30+
- fix EnableSecurityGroups if resource is not running on a domain controller
3131
- HyperV:
32-
- remove unused code after migration to HyperVDsc
33-
32+
- remove unused code after migration to HyperVDsc
33+
- Pipeline
34+
- Updated to latest Sampler files and update an vmImage reference to `ubuntu-latest`
3435

3536
## [0.9.0] - 2023-02-08
3637

Resolve-Dependency.ps1

Lines changed: 90 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ try
155155

156156
$PSBoundParameters.Add($parameterName, $variableValue)
157157

158-
Set-Variable -Name $parameterName -value $variableValue -Force -ErrorAction 'SilentlyContinue'
158+
Set-Variable -Name $parameterName -Value $variableValue -Force -ErrorAction 'SilentlyContinue'
159159
}
160160
catch
161161
{
@@ -171,19 +171,32 @@ catch
171171

172172
Write-Progress -Activity 'Bootstrap:' -PercentComplete 0 -CurrentOperation 'NuGet Bootstrap'
173173

174-
# TODO: This should handle the parameter $AllowOldPowerShellGetModule.
175-
$powerShellGetModule = Import-Module -Name 'PowerShellGet' -MinimumVersion '2.0' -ErrorAction 'SilentlyContinue' -PassThru
174+
$importModuleParameters = @{
175+
Name = 'PowerShellGet'
176+
MinimumVersion = '2.0'
177+
ErrorAction = 'SilentlyContinue'
178+
PassThru = $true
179+
}
180+
181+
if ($AllowOldPowerShellGetModule)
182+
{
183+
$importModuleParameters.Remove('MinimumVersion')
184+
}
185+
186+
$powerShellGetModule = Import-Module @importModuleParameters
176187

177188
# Install the package provider if it is not available.
178-
$nuGetProvider = Get-PackageProvider -Name 'NuGet' -ListAvailable | Select-Object -First 1
189+
$nuGetProvider = Get-PackageProvider -Name 'NuGet' -ListAvailable -ErrorAction 'SilentlyContinue' |
190+
Select-Object -First 1
179191

180192
if (-not $powerShellGetModule -and -not $nuGetProvider)
181193
{
182194
$providerBootstrapParameters = @{
183-
Name = 'nuget'
195+
Name = 'NuGet'
184196
Force = $true
185197
ForceBootstrap = $true
186198
ErrorAction = 'Stop'
199+
Scope = $Scope
187200
}
188201

189202
switch ($PSBoundParameters.Keys)
@@ -198,26 +211,15 @@ if (-not $powerShellGetModule -and -not $nuGetProvider)
198211
$providerBootstrapParameters.Add('ProxyCredential', $ProxyCredential)
199212
}
200213

201-
'Scope'
202-
{
203-
$providerBootstrapParameters.Add('Scope', $Scope)
204-
}
205-
206214
'AllowPrerelease'
207215
{
208216
$providerBootstrapParameters.Add('AllowPrerelease', $AllowPrerelease)
209217
}
210218
}
211219

212-
if ($AllowPrerelease)
213-
{
214-
$providerBootstrapParameters.Add('AllowPrerelease', $true)
215-
}
216-
217220
Write-Information -MessageData 'Bootstrap: Installing NuGet Package Provider from the web (Make sure Microsoft addresses/ranges are allowed).'
218221

219-
# TODO: This does not handle a private Gallery yet.
220-
$null = Install-PackageProvider @providerBootstrapParams
222+
$null = Install-PackageProvider @providerBootstrapParameters
221223

222224
$nuGetProvider = Get-PackageProvider -Name 'NuGet' -ListAvailable | Select-Object -First 1
223225

@@ -285,47 +287,81 @@ try
285287
# Versions below 2.0 are considered old, unreliable & not recommended
286288
if (-not $powerShellGetVersion -or ($powerShellGetVersion -lt [System.Version] '2.0' -and -not $AllowOldPowerShellGetModule))
287289
{
288-
Write-Progress -Activity 'Bootstrap:' -PercentComplete 40 -CurrentOperation 'Installing newer version of PowerShellGet'
289-
290-
$installPowerShellGetParameters = @{
291-
Name = 'PowerShellGet'
292-
Force = $True
293-
SkipPublisherCheck = $true
294-
AllowClobber = $true
295-
Scope = $Scope
296-
Repository = $Gallery
297-
}
290+
Write-Progress -Activity 'Bootstrap:' -PercentComplete 40 -CurrentOperation 'Fetching newer version of PowerShellGet'
298291

299-
switch ($PSBoundParameters.Keys)
292+
# PowerShellGet module not found, installing or saving it.
293+
if ($PSDependTarget -in 'CurrentUser', 'AllUsers')
300294
{
301-
'Proxy'
302-
{
303-
$installPowerShellGetParameters.Add('Proxy', $Proxy)
304-
}
295+
Write-Debug -Message "PowerShellGet module not found. Attempting to install from Gallery $Gallery."
305296

306-
'ProxyCredential'
307-
{
308-
$installPowerShellGetParameters.Add('ProxyCredential', $ProxyCredential)
297+
Write-Warning -Message "Installing PowerShellGet in $PSDependTarget Scope."
298+
299+
$installPowerShellGetParameters = @{
300+
Name = 'PowerShellGet'
301+
Force = $true
302+
SkipPublisherCheck = $true
303+
AllowClobber = $true
304+
Scope = $Scope
305+
Repository = $Gallery
309306
}
310307

311-
'GalleryCredential'
308+
switch ($PSBoundParameters.Keys)
312309
{
313-
$installPowerShellGetParameters.Add('Credential', $GalleryCredential)
310+
'Proxy'
311+
{
312+
$installPowerShellGetParameters.Add('Proxy', $Proxy)
313+
}
314+
315+
'ProxyCredential'
316+
{
317+
$installPowerShellGetParameters.Add('ProxyCredential', $ProxyCredential)
318+
}
319+
320+
'GalleryCredential'
321+
{
322+
$installPowerShellGetParameters.Add('Credential', $GalleryCredential)
323+
}
314324
}
315-
'AllowPrerelease'
316-
{
317-
$installPowerShellGetParameters.Add('AllowPrerelease', $AllowPrerelease)
325+
326+
Write-Progress -Activity 'Bootstrap:' -PercentComplete 60 -CurrentOperation 'Installing newer version of PowerShellGet'
327+
328+
Install-Module @installPowerShellGetParameters
329+
}
330+
else
331+
{
332+
Write-Debug -Message "PowerShellGet module not found. Attempting to Save from Gallery $Gallery to $PSDependTarget"
333+
334+
$saveModuleParameters = @{
335+
Name = 'PowerShellGet'
336+
Repository = $Gallery
337+
Path = $PSDependTarget
338+
Force = $true
318339
}
340+
341+
Write-Progress -Activity 'Bootstrap:' -PercentComplete 60 -CurrentOperation "Saving PowerShellGet from $Gallery to $Scope"
342+
343+
Save-Module @saveModuleParameters
319344
}
320345

321-
Write-Progress -Activity 'Bootstrap:' -PercentComplete 60 -CurrentOperation 'Installing newer version of PowerShellGet'
346+
Write-Debug -Message 'Removing previous versions of PowerShellGet and PackageManagement from session'
347+
348+
Get-Module -Name 'PowerShellGet' -All | Remove-Module -Force -ErrorAction 'SilentlyContinue'
349+
Get-Module -Name 'PackageManagement' -All | Remove-Module -Force
350+
351+
Write-Progress -Activity 'Bootstrap:' -PercentComplete 65 -CurrentOperation 'Loading latest version of PowerShellGet'
322352

323-
Install-Module @installPowerShellGetParameters
353+
Write-Debug -Message 'Importing latest PowerShellGet and PackageManagement versions into session'
324354

325-
Remove-Module -Name 'PowerShellGet' -Force -ErrorAction 'SilentlyContinue'
326-
Remove-Module -Name 'PackageManagement' -Force
355+
if ($AllowOldPowerShellGetModule)
356+
{
357+
$powerShellGetModule = Import-Module -Name 'PowerShellGet' -Force -PassThru
358+
}
359+
else
360+
{
361+
Import-Module -Name 'PackageManagement' -MinimumVersion '1.4.8.1' -Force
327362

328-
$powerShellGetModule = Import-Module PowerShellGet -Force -PassThru
363+
$powerShellGetModule = Import-Module -Name 'PowerShellGet' -MinimumVersion '2.2.5' -Force -PassThru
364+
}
329365

330366
$powerShellGetVersion = $powerShellGetModule.Version.ToString()
331367

@@ -395,7 +431,7 @@ try
395431
$saveModuleParameters.add('MinimumVersion', $MinimumPSDependVersion)
396432
}
397433

398-
Write-Progress -Activity 'Bootstrap:' -PercentComplete 75 -CurrentOperation "Saving & Importing PSDepend from $Gallery to $Scope"
434+
Write-Progress -Activity 'Bootstrap:' -PercentComplete 75 -CurrentOperation "Saving PSDepend from $Gallery to $Scope"
399435

400436
Save-Module @saveModuleParameters
401437
}
@@ -438,13 +474,15 @@ try
438474
}
439475
else
440476
{
441-
Write-Verbose "PowerShell-Yaml is already available"
477+
Write-Verbose -Message 'PowerShell-Yaml is already available'
442478
}
479+
480+
Write-Progress -Activity 'Bootstrap:' -PercentComplete 88 -CurrentOperation 'Importing PowerShell module PowerShell-Yaml'
443481
}
444482

445483
Write-Progress -Activity 'Bootstrap:' -PercentComplete 90 -CurrentOperation 'Invoke PSDepend'
446484

447-
Write-Progress -Activity "PSDepend:" -PercentComplete 0 -CurrentOperation "Restoring Build Dependencies"
485+
Write-Progress -Activity 'PSDepend:' -PercentComplete 0 -CurrentOperation 'Restoring Build Dependencies'
448486

449487
if (Test-Path -Path $DependencyFile)
450488
{
@@ -457,9 +495,9 @@ try
457495
Invoke-PSDepend @psDependParameters
458496
}
459497

460-
Write-Progress -Activity "PSDepend:" -PercentComplete 100 -CurrentOperation "Dependencies restored" -Completed
498+
Write-Progress -Activity 'PSDepend:' -PercentComplete 100 -CurrentOperation 'Dependencies restored' -Completed
461499

462-
Write-Progress -Activity 'Bootstrap:' -PercentComplete 100 -CurrentOperation "Bootstrap complete" -Completed
500+
Write-Progress -Activity 'Bootstrap:' -PercentComplete 100 -CurrentOperation 'Bootstrap complete' -Completed
463501
}
464502
finally
465503
{
@@ -474,7 +512,7 @@ finally
474512
Write-Verbose -Message "Reverting private package repository '$Gallery' to previous location URI:s."
475513

476514
$registerPSRepositoryParameters = @{
477-
Name = $previousRegisteredRepository.Name
515+
Name = $previousRegisteredRepository.Name
478516
InstallationPolicy = $previousRegisteredRepository.InstallationPolicy
479517
}
480518

@@ -511,5 +549,5 @@ finally
511549
}
512550
}
513551

514-
Write-Verbose -Message "Project Bootstrapped, returning to Invoke-Build"
552+
Write-Verbose -Message 'Project Bootstrapped, returning to Invoke-Build.'
515553
}

Resolve-Dependency.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@{
22
Gallery = 'PSGallery'
33
AllowPrerelease = $true
4-
WithYAML = $false # Will also bootstrap PowerShell-Yaml to read other config files
4+
WithYAML = $true
55
}

azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ stages:
127127
dependsOn:
128128
- test_windows_ps
129129
pool:
130-
vmImage: 'ubuntu 18.04'
130+
vmImage: 'ubuntu-latest'
131131
timeoutInMinutes: 5
132132
steps:
133133
- pwsh: |

0 commit comments

Comments
 (0)