Skip to content

Commit

Permalink
Merge pull request #5721 from NikCharlebois/Added-Proxy-to-Dependency…
Browse files Browse the repository at this point in the history
…-Management

Added proxy to dependency management
  • Loading branch information
NikCharlebois authored Feb 4, 2025
2 parents d448493 + bfc1544 commit 5b73424
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Changed the InsiderRiskTypes property to a string array.
* MISC
* Changed the CIMInstance logic of various resources to us common logic.
* Added support for specifying a proxy in Update-M365DSCModule.

# 1.25.129.3

Expand Down
34 changes: 28 additions & 6 deletions Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ function Test-M365DSCParameterState
$propertyName = $existingDrift.Keys[0]
$value = $existingDrift."$propertyName"
$start = $value.IndexOf('</CurrentValue>')
$currentValue = $value.Substring(0, $start).Replace('<CurrentValue>', '')
$currentValue = $value.Substring(0, $start).Replace('<CurrentValue>', '')
$desiredValue = $value.Substring($start+15, ($value.Length)-($start+15)).Replace('<DesiredValue>', '').Replace('</DesiredValue>', '')
$DriftObject.DriftInfo.Add($propertyName, @{
PropertyName = $propertyName
Expand Down Expand Up @@ -3256,9 +3256,14 @@ function Update-M365DSCDependencies
[Parameter()]
[Switch]
$ValidateOnly,

[Parameter()]
[ValidateSet("CurrentUser", "AllUsers")]
$Scope = "AllUsers"
$Scope = "AllUsers",

[Parameter()]
[System.String]
$Proxy
)

try
Expand All @@ -3273,6 +3278,12 @@ function Update-M365DSCDependencies

$returnValue = @()

$params = @{}
if (-not [System.String]::IsNullOrEmpty($Proxy))
{
$params.Add('Proxy', $Proxy)
}

foreach ($dependency in $dependencies)
{
Write-Progress -Activity 'Scanning dependencies' -PercentComplete ($i / $dependencies.Count * 100)
Expand Down Expand Up @@ -3328,7 +3339,7 @@ function Update-M365DSCDependencies
Remove-Module 'Microsoft.Graph.Authentication' -Force -ErrorAction SilentlyContinue
}
Remove-Module $dependency.ModuleName -Force -ErrorAction SilentlyContinue
Install-Module $dependency.ModuleName -RequiredVersion $dependency.RequiredVersion -AllowClobber -Force -Scope "$Scope"
Install-Module $dependency.ModuleName -RequiredVersion $dependency.RequiredVersion -AllowClobber -Force -Scope "$Scope" @Params
}
}

Expand Down Expand Up @@ -4788,11 +4799,22 @@ function Update-M365DSCModule
param(
[Parameter()]
[ValidateSet("CurrentUser", "AllUsers")]
$Scope = "AllUsers"
$Scope = "AllUsers",

[Parameter()]
[System.String]
$Proxy
)

$params = @{}

if (-not [System.String]::IsNullOrEmpty($proxy))
{
$params.Add('Proxy', $Proxy)
}
try
{
Update-Module -Name 'Microsoft365DSC' -ErrorAction Stop
Update-Module -Name 'Microsoft365DSC' @Params -ErrorAction Stop
}
catch
{
Expand Down Expand Up @@ -4821,7 +4843,7 @@ function Update-M365DSCModule
-Source $($MyInvocation.MyCommand.Source)
throw $_
}
Update-M365DSCDependencies -Scope $Scope
Update-M365DSCDependencies -Scope $Scope -Proxy $Proxy
Uninstall-M365DSCOutdatedDependencies
}

Expand Down

0 comments on commit 5b73424

Please sign in to comment.