Skip to content

Commit

Permalink
Updated to latest Sampler files (#211)
Browse files Browse the repository at this point in the history
  • Loading branch information
raandree authored Apr 18, 2023
1 parent d99f804 commit 37e2841
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 66 deletions.
25 changes: 13 additions & 12 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- AddsDomainController:
- add UnprotectFromAccidentalDeletion to allow dc promote if an existing AD computer account is protected
- AllowPasswordReplication and DenyPasswordReplication Variables for RODCs
- add UnprotectFromAccidentalDeletion to allow dc promote if an existing AD computer account is protected
- AllowPasswordReplication and DenyPasswordReplication Variables for RODCs
- AzureConnectedMachine:
- Composite to install and configure the Azure Connected Machine Agent
- Composite to install and configure the Azure Connected Machine Agent
- DhcpServerAuthorization:
- new resource to authorize DHCP server in AD
- new resource to authorize DHCP server in AD
- FailoverCluster:
- add Networks support
- add installation of required Windows Features
- update documentation
- add Networks support
- add installation of required Windows Features
- update documentation
- HyperVReplica
- new resource to configure replication of Hyper-V virtual machines
- new resource to configure replication of Hyper-V virtual machines
- HyperVState
- new resource to control state parameters of Hyper-V virtual machines
- new resource to control state parameters of Hyper-V virtual machines

### Changed

- Fixed Typo in AddsDomainController documentation
- DHCPServer:
- fix EnableSecurityGroups if resource is not running on a domain controller
- fix EnableSecurityGroups if resource is not running on a domain controller
- HyperV:
- remove unused code after migration to HyperVDsc

- remove unused code after migration to HyperVDsc
- Pipeline
- Updated to latest Sampler files and update an vmImage reference to `ubuntu-latest`

## [0.9.0] - 2023-02-08

Expand Down
142 changes: 90 additions & 52 deletions Resolve-Dependency.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ try

$PSBoundParameters.Add($parameterName, $variableValue)

Set-Variable -Name $parameterName -value $variableValue -Force -ErrorAction 'SilentlyContinue'
Set-Variable -Name $parameterName -Value $variableValue -Force -ErrorAction 'SilentlyContinue'
}
catch
{
Expand All @@ -171,19 +171,32 @@ catch

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

# TODO: This should handle the parameter $AllowOldPowerShellGetModule.
$powerShellGetModule = Import-Module -Name 'PowerShellGet' -MinimumVersion '2.0' -ErrorAction 'SilentlyContinue' -PassThru
$importModuleParameters = @{
Name = 'PowerShellGet'
MinimumVersion = '2.0'
ErrorAction = 'SilentlyContinue'
PassThru = $true
}

if ($AllowOldPowerShellGetModule)
{
$importModuleParameters.Remove('MinimumVersion')
}

$powerShellGetModule = Import-Module @importModuleParameters

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

if (-not $powerShellGetModule -and -not $nuGetProvider)
{
$providerBootstrapParameters = @{
Name = 'nuget'
Name = 'NuGet'
Force = $true
ForceBootstrap = $true
ErrorAction = 'Stop'
Scope = $Scope
}

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

'Scope'
{
$providerBootstrapParameters.Add('Scope', $Scope)
}

'AllowPrerelease'
{
$providerBootstrapParameters.Add('AllowPrerelease', $AllowPrerelease)
}
}

if ($AllowPrerelease)
{
$providerBootstrapParameters.Add('AllowPrerelease', $true)
}

Write-Information -MessageData 'Bootstrap: Installing NuGet Package Provider from the web (Make sure Microsoft addresses/ranges are allowed).'

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

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

Expand Down Expand Up @@ -285,47 +287,81 @@ try
# Versions below 2.0 are considered old, unreliable & not recommended
if (-not $powerShellGetVersion -or ($powerShellGetVersion -lt [System.Version] '2.0' -and -not $AllowOldPowerShellGetModule))
{
Write-Progress -Activity 'Bootstrap:' -PercentComplete 40 -CurrentOperation 'Installing newer version of PowerShellGet'

$installPowerShellGetParameters = @{
Name = 'PowerShellGet'
Force = $True
SkipPublisherCheck = $true
AllowClobber = $true
Scope = $Scope
Repository = $Gallery
}
Write-Progress -Activity 'Bootstrap:' -PercentComplete 40 -CurrentOperation 'Fetching newer version of PowerShellGet'

switch ($PSBoundParameters.Keys)
# PowerShellGet module not found, installing or saving it.
if ($PSDependTarget -in 'CurrentUser', 'AllUsers')
{
'Proxy'
{
$installPowerShellGetParameters.Add('Proxy', $Proxy)
}
Write-Debug -Message "PowerShellGet module not found. Attempting to install from Gallery $Gallery."

'ProxyCredential'
{
$installPowerShellGetParameters.Add('ProxyCredential', $ProxyCredential)
Write-Warning -Message "Installing PowerShellGet in $PSDependTarget Scope."

$installPowerShellGetParameters = @{
Name = 'PowerShellGet'
Force = $true
SkipPublisherCheck = $true
AllowClobber = $true
Scope = $Scope
Repository = $Gallery
}

'GalleryCredential'
switch ($PSBoundParameters.Keys)
{
$installPowerShellGetParameters.Add('Credential', $GalleryCredential)
'Proxy'
{
$installPowerShellGetParameters.Add('Proxy', $Proxy)
}

'ProxyCredential'
{
$installPowerShellGetParameters.Add('ProxyCredential', $ProxyCredential)
}

'GalleryCredential'
{
$installPowerShellGetParameters.Add('Credential', $GalleryCredential)
}
}
'AllowPrerelease'
{
$installPowerShellGetParameters.Add('AllowPrerelease', $AllowPrerelease)

Write-Progress -Activity 'Bootstrap:' -PercentComplete 60 -CurrentOperation 'Installing newer version of PowerShellGet'

Install-Module @installPowerShellGetParameters
}
else
{
Write-Debug -Message "PowerShellGet module not found. Attempting to Save from Gallery $Gallery to $PSDependTarget"

$saveModuleParameters = @{
Name = 'PowerShellGet'
Repository = $Gallery
Path = $PSDependTarget
Force = $true
}

Write-Progress -Activity 'Bootstrap:' -PercentComplete 60 -CurrentOperation "Saving PowerShellGet from $Gallery to $Scope"

Save-Module @saveModuleParameters
}

Write-Progress -Activity 'Bootstrap:' -PercentComplete 60 -CurrentOperation 'Installing newer version of PowerShellGet'
Write-Debug -Message 'Removing previous versions of PowerShellGet and PackageManagement from session'

Get-Module -Name 'PowerShellGet' -All | Remove-Module -Force -ErrorAction 'SilentlyContinue'
Get-Module -Name 'PackageManagement' -All | Remove-Module -Force

Write-Progress -Activity 'Bootstrap:' -PercentComplete 65 -CurrentOperation 'Loading latest version of PowerShellGet'

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

Remove-Module -Name 'PowerShellGet' -Force -ErrorAction 'SilentlyContinue'
Remove-Module -Name 'PackageManagement' -Force
if ($AllowOldPowerShellGetModule)
{
$powerShellGetModule = Import-Module -Name 'PowerShellGet' -Force -PassThru
}
else
{
Import-Module -Name 'PackageManagement' -MinimumVersion '1.4.8.1' -Force

$powerShellGetModule = Import-Module PowerShellGet -Force -PassThru
$powerShellGetModule = Import-Module -Name 'PowerShellGet' -MinimumVersion '2.2.5' -Force -PassThru
}

$powerShellGetVersion = $powerShellGetModule.Version.ToString()

Expand Down Expand Up @@ -395,7 +431,7 @@ try
$saveModuleParameters.add('MinimumVersion', $MinimumPSDependVersion)
}

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

Save-Module @saveModuleParameters
}
Expand Down Expand Up @@ -438,13 +474,15 @@ try
}
else
{
Write-Verbose "PowerShell-Yaml is already available"
Write-Verbose -Message 'PowerShell-Yaml is already available'
}

Write-Progress -Activity 'Bootstrap:' -PercentComplete 88 -CurrentOperation 'Importing PowerShell module PowerShell-Yaml'
}

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

Write-Progress -Activity "PSDepend:" -PercentComplete 0 -CurrentOperation "Restoring Build Dependencies"
Write-Progress -Activity 'PSDepend:' -PercentComplete 0 -CurrentOperation 'Restoring Build Dependencies'

if (Test-Path -Path $DependencyFile)
{
Expand All @@ -457,9 +495,9 @@ try
Invoke-PSDepend @psDependParameters
}

Write-Progress -Activity "PSDepend:" -PercentComplete 100 -CurrentOperation "Dependencies restored" -Completed
Write-Progress -Activity 'PSDepend:' -PercentComplete 100 -CurrentOperation 'Dependencies restored' -Completed

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

$registerPSRepositoryParameters = @{
Name = $previousRegisteredRepository.Name
Name = $previousRegisteredRepository.Name
InstallationPolicy = $previousRegisteredRepository.InstallationPolicy
}

Expand Down Expand Up @@ -511,5 +549,5 @@ finally
}
}

Write-Verbose -Message "Project Bootstrapped, returning to Invoke-Build"
Write-Verbose -Message 'Project Bootstrapped, returning to Invoke-Build.'
}
2 changes: 1 addition & 1 deletion Resolve-Dependency.psd1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@{
Gallery = 'PSGallery'
AllowPrerelease = $true
WithYAML = $false # Will also bootstrap PowerShell-Yaml to read other config files
WithYAML = $true
}
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ stages:
dependsOn:
- test_windows_ps
pool:
vmImage: 'ubuntu 18.04'
vmImage: 'ubuntu-latest'
timeoutInMinutes: 5
steps:
- pwsh: |
Expand Down

0 comments on commit 37e2841

Please sign in to comment.