Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev' into Fixes-microsoft#2337
Browse files Browse the repository at this point in the history
  • Loading branch information
NikCharlebois committed Oct 17, 2022
2 parents 64f3bbc + 5ff236b commit ef63221
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 126 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
FIXES [#2008](https://github.com/microsoft/Microsoft365DSC/issues/2008)
* Fixed an issue where the log engine was throwing an error when trying to write to the event log from an Azure runbook.
FIXES [#2236](https://github.com/microsoft/Microsoft365DSC/issues/2236)
* Standardizing the functions to test versions of the module and dependencies.
FIXES [#2232](https://github.com/microsoft/Microsoft365DSC/issues/2232)


# 1.22.1012.1

Expand Down
1 change: 0 additions & 1 deletion Modules/Microsoft365DSC/Microsoft365DSC.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@
'Set-M365DSCAgentCertificateConfiguration',
'Start-M365DSCConfiguration',
'Test-M365DSCAgent',
'Test-M365DSCDependencies',
'Test-M365DSCDependenciesForNewVersions',
'Test-M365DSCModuleValidity',
'Uninstall-M365DSCOutdatedDependencies',
Expand Down
4 changes: 2 additions & 2 deletions Modules/Microsoft365DSC/Modules/M365DSCReverse.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ function Start-M365DSCConfigurationExtract
# PowerShell Gallery
try
{
Test-M365DSCNewVersionAvailable
Test-M365DSCModuleValidity
}
catch
{
Add-M365DSCEvent -Message $_ -Source 'M365DSCReverse::Test-M365DSCNewVersionAvailable'
Add-M365DSCEvent -Message $_ -Source 'M365DSCReverse::Test-M365DSCModuleValidity'
}
try
{
Expand Down
103 changes: 2 additions & 101 deletions Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,7 @@ function Export-M365DSCConfiguration
$data.Add('MaxProcesses', $null -ne $MaxProcesses)
#endregion

$outdatedOrMissingAssemblies = Test-M365DSCDependencies
$outdatedOrMissingAssemblies = Test-M365DSCDependenciesForNewVersions
if ($outdatedOrMissingAssemblies)
{
if (([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))
Expand Down Expand Up @@ -1260,7 +1260,7 @@ function Confirm-M365DSCDependencies
if (-not $Script:M365DSCDependenciesValidated)
{
Write-Verbose -Message 'Dependencies were not already validated.'
$result = Test-M365DSCDependencies
$result = Test-M365DSCDependenciesForNewVersions
if ($result.Length -gt 0)
{
$ErrorMessage = "The following dependencies need updating:`r`n"
Expand Down Expand Up @@ -2529,39 +2529,6 @@ function Test-M365DSCDependenciesForNewVersions
}
}

<#
.Description
This function checks if all M365DSC dependencies are installed
.Functionality
Internal, Hidden
#>
function Test-M365DSCDependencies
{
[CmdletBinding()]
$currentPath = Join-Path -Path $PSScriptRoot -ChildPath '..\' -Resolve
$manifest = Import-PowerShellDataFile "$currentPath/Dependencies/Manifest.psd1"
$dependencies = $manifest.Dependencies
$missingDependencies = @()
foreach ($dependency in $dependencies)
{
try
{
Write-Verbose -Message "{$($dependency.ModuleName)} version $($dependency.RequiredVersion)"
$module = Get-Module $dependency.ModuleName -ListAvailable | Where-Object -FilterScript { $_.Version -eq $dependency.RequiredVersion }
if (-not $module)
{
$missingDependencies += $dependency
}
}
catch
{
Write-Verbose -Message "Error: $_"
}
}
return $missingDependencies
}

<#
.Description
This function installs all missing M365DSC dependencies
Expand Down Expand Up @@ -3030,71 +2997,6 @@ function Get-M365DSCExportContentForResource
return $content
}

<#
.Description
This function check if the currently installed version of M365DSC is the most recent one,
available in the PowerShell Gallery
.Example
Test-M365DSCNewVersionAvailable
.Functionality
Public
#>
function Test-M365DSCNewVersionAvailable
{
[CmdletBinding()]
param()

if ('AzureAutomation/' -eq $env:AZUREPS_HOST_ENVIRONMENT)
{
$message = 'Skipping check for newer version of Microsoft 365 DSC due to Azure Automation Environment restrictions.'
Write-Verbose -Message $message
return
}

try
{
if ($null -eq $Global:M365DSCNewVersionNotification)
{
# Get current module used
$currentVersion = Get-Module 'Microsoft365DSC' -ErrorAction Stop

# Get module in the Gallery
$JobID = Start-Job { Find-Module 'Microsoft365DSC' -ErrorAction Stop }
$Timeout = $true
for ($i = 0; $i -lt 10; $i++)
{
if ((Get-Job $JobID.id).State -notmatch 'Running')
{
$Timeout = $false
break;
}
Start-Sleep -Seconds 1
}
if ($Timeout)
{
return
}
$GalleryVersion = Get-Job $JobID.id | Receive-Job
if ([Version]($GalleryVersion.Version) -gt [Version]($currentVersion.Version))
{
$message = "A NEWER VERSION OF MICROSOFT365DSC {v$($GalleryVersion.Version)} IS AVAILABLE IN THE POWERSHELL GALLERY. TO UPDATE, RUN:`r`nInstall-Module Microsoft365DSC -Force -AllowClobber"
Write-Host $message `
-ForegroundColor 'White' `
-BackgroundColor 'DarkGray'
Write-Verbose -Message $message
}
$Global:M365DSCNewVersionNotification = 'AlreadyShown'
}
}
catch
{
Write-Verbose -Message $_
Add-M365DSCEvent -Message $_ -EntryType 'Error' `
-EventID 1 -Source $($MyInvocation.MyCommand.Source)
}
}

<#
.Description
Expand Down Expand Up @@ -3851,7 +3753,6 @@ Export-ModuleMember -Function @(
'Split-ArrayByParts',
'Test-M365DSCDependenciesForNewVersions',
'Test-M365DSCModuleValidity',
'Test-M365DSCNewVersionAvailable',
'Test-M365DSCParameterState',
'Uninstall-M365DSCOutdatedDependencies',
'Update-M365DSCDependencies',
Expand Down
21 changes: 0 additions & 21 deletions docs/docs/user-guide/cmdlets/Test-M365DSCNewVersionAvailable.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ nav:
- 'Test-M365DSCAgent': 'user-guide/cmdlets/Test-M365DSCAgent.md'
- 'Test-M365DSCDependenciesForNewVersions': 'user-guide/cmdlets/Test-M365DSCDependenciesForNewVersions.md'
- 'Test-M365DSCModuleValidity': 'user-guide/cmdlets/Test-M365DSCModuleValidity.md'
- 'Test-M365DSCNewVersionAvailable': 'user-guide/cmdlets/Test-M365DSCNewVersionAvailable.md'
- 'Uninstall-M365DSCOutdatedDependencies': 'user-guide/cmdlets/Uninstall-M365DSCOutdatedDependencies.md'
- 'Update-M365DSCAllowedGraphScopes': 'user-guide/cmdlets/Update-M365DSCAllowedGraphScopes.md'
- 'Update-M365DSCAzureAdApplication': 'user-guide/cmdlets/Update-M365DSCAzureAdApplication.md'
Expand Down

0 comments on commit ef63221

Please sign in to comment.