Skip to content

Commit

Permalink
Merge pull request #845 from NikCharlebois/Improved-Error-Logging
Browse files Browse the repository at this point in the history
Out-of-Band Release 1.20.1016.1
  • Loading branch information
NikCharlebois authored Oct 16, 2020
2 parents 6fd40f1 + 20be467 commit ffc3540
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 24 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Change log for Microsoft365DSC

## 1.20.1021.1
## 1.20.1016.1

* Fixed a permissions issue with the
* Fixed a permissions issue with the
Install-M365DSCDevBranch cmdlet (Issue #699 & #826)
* DEPENDENCIES
* MSCloudLoginAssistant Updated to 1.0.41;
* SharePointPnPPowerShellOnline Updated to 3.26.2010.0;
* MISC
* Improved Error log to include StackTrace for additional
Expand Down
6 changes: 3 additions & 3 deletions Modules/Microsoft365DSC/Microsoft365DSC.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
#
# Generated by: Microsoft Corporation
#
# Generated on: 2020-10-14
# Generated on: 2020-10-16

@{

# Script module or binary module file associated with this manifest.
# RootModule = ''

# Version number of this module.
ModuleVersion = '1.20.1014.1'
ModuleVersion = '1.20.1016.1'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down Expand Up @@ -93,7 +93,7 @@
},
@{
ModuleName = "MSCloudLoginAssistant"
RequiredVersion = "1.0.40"
RequiredVersion = "1.0.41"
},
@{
ModuleName = "ReverseDSC"
Expand Down
38 changes: 19 additions & 19 deletions Modules/Microsoft365DSC/Modules/M365DSCLogEngine.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -86,37 +86,37 @@ function Add-M365DSCEvent

$LogName = 'M365DSC'

if ([System.Diagnostics.EventLog]::SourceExists($Source))
{
$sourceLogName = [System.Diagnostics.EventLog]::LogNameFromSourceName($Source, ".")
if ($LogName -ne $sourceLogName)
{
Write-Verbose -Message "[ERROR] Specified source {$Source} already exists on log {$sourceLogName}"
return
}
}
else
try
{
if ([System.Diagnostics.EventLog]::Exists($LogName) -eq $false)
if ([System.Diagnostics.EventLog]::SourceExists($Source))
{
#Create event log
$null = New-EventLog -LogName $LogName -Source $Source
$sourceLogName = [System.Diagnostics.EventLog]::LogNameFromSourceName($Source, ".")
if ($LogName -ne $sourceLogName)
{
Write-Verbose -Message "[ERROR] Specified source {$Source} already exists on log {$sourceLogName}"
return
}
}
else
{
[System.Diagnostics.EventLog]::CreateEventSource($Source, $LogName)
if ([System.Diagnostics.EventLog]::Exists($LogName) -eq $false)
{
#Create event log
$null = New-EventLog -LogName $LogName -Source $Source
}
else
{
[System.Diagnostics.EventLog]::CreateEventSource($Source, $LogName)
}
}
}

try
{
Write-EventLog -LogName $LogName -Source $Source `
-EventID $EventID -Message $Message -EntryType $EntryType
}
catch
{
Write-Verbose -Message $_
Add-M365DSCEvent -Message $_ -EntryType 'Error' `
-EventID 1 -Source $($MyInvocation.MyCommand.Source)
$Message = "Could not write to event log"
New-M365DSCLogEntry -Error $_ -Message $Message -Source "[M365DSCLogEngine]"
}
}

0 comments on commit ffc3540

Please sign in to comment.