Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
608c614
Removed IncludeRules from settings that overrides defaults
dpaulson45 Aug 9, 2021
0aba0e1
Adding PSReviewUnusedParameter to exclude rule and removed overrides
dpaulson45 Aug 9, 2021
7ba53dc
Added OutputType
dpaulson45 Aug 9, 2021
687a567
Addressed Get-Encoding being an alias
dpaulson45 Aug 9, 2021
edf26a0
Fixed bug in analyzer engine
dpaulson45 Aug 9, 2021
3a1400c
Addressed PSUseDeclaredVarsMoreThanAssignments
dpaulson45 Aug 9, 2021
fc185af
Fixed Pester Test
dpaulson45 Aug 9, 2021
04193e1
Addressed PSAvoidTrailingWhitespace
dpaulson45 Aug 9, 2021
b7715e8
Addressed PSPossibleIncorrectComparisonWithNull
dpaulson45 Aug 9, 2021
d142c86
Addressed PSAvoidUsingWMICmdlet
dpaulson45 Aug 9, 2021
2a9c587
Addressed PSUseProcessBlockForPipelineCommand
dpaulson45 Aug 9, 2021
e2ea18b
Addressed PSAvoidAssignmentToAutomaticVariable
dpaulson45 Aug 9, 2021
5fbbe5d
Fix script analyzer warnings
bill-long Aug 9, 2021
9f63558
Addressed PSAvoidUsingComputerNameHardcoded
dpaulson45 Aug 9, 2021
6f0de00
Override PSUseApprovedVerbs on Load-Module
dpaulson45 Aug 9, 2021
0a23d4c
Override PSUseShouldProcessForStateChangingFunctions on Start-SleepWi…
dpaulson45 Aug 9, 2021
f65c45b
Moved Shared Functions from Test-ExchangeAVExclusions to local
dpaulson45 Aug 9, 2021
8ecb5c4
Forgot to include missing parameter in Diagnostics.CodeAnalysis.Suppr…
dpaulson45 Aug 9, 2021
785ab35
Addressed PSUseDeclaredVarsMoreThanAssignments with override
dpaulson45 Aug 9, 2021
ea30f47
Addressing PSAvoidUsingPositionalParameters
dpaulson45 Aug 9, 2021
50e53ce
Adding in override for ManagedAvailabilityTroubleshooter
dpaulson45 Aug 9, 2021
9eff607
Correct override justification typo
dpaulson45 Aug 9, 2021
d736ca0
replaced quote type
dpaulson45 Aug 9, 2021
deb6495
Move build back to Azure
bill-long Aug 9, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .build/BuildFunctions/Get-EmbeddedFileList.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
function Get-EmbeddedFileList {
[CmdletBinding()]
[OutputType([string[]])]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', 'FilesAlreadyAdded', Justification = 'Incorrect rule result')]
param (
[Parameter()]
[string]
Expand Down
1 change: 1 addition & 0 deletions .build/BuildFunctions/Test-PathCaseSensitive.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

function Test-PathCaseSensitive {
[CmdletBinding()]
[OutputType("System.Boolean")]
param (
[Parameter(Mandatory = $true)]
[string]
Expand Down
6 changes: 3 additions & 3 deletions .build/CodeFormatter.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification = '$filesFailed is being used.')]
[CmdletBinding()]
param(
[Switch]
Expand All @@ -27,7 +27,7 @@ $filesFailed = $false

# MD files must NOT have a BOM
Get-ChildItem -Path $repoRoot -Include *.md -Recurse | ForEach-Object {
$encoding = Get-Encoding $_
$encoding = Get-PsOneEncoding $_
if ($encoding.BOM) {
Write-Warning "MD file has BOM: $($_.FullName)"
if ($Save) {
Expand All @@ -47,7 +47,7 @@ Get-ChildItem -Path $repoRoot -Include *.md -Recurse | ForEach-Object {

foreach ($file in $scriptFiles) {
# PS1 files must have a BOM
$encoding = Get-Encoding $file
$encoding = Get-PsOneEncoding $file
if (-not $encoding.BOM) {
Write-Warning "File has no BOM: $file"
if ($Save) {
Expand Down
1 change: 1 addition & 0 deletions .build/Load-Module.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Licensed under the MIT License.

function Load-Module {
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseApprovedVerbs', '', Justification = 'Prefer verb usage')]
[CmdletBinding()]
[OutputType([bool])]
param (
Expand Down
5 changes: 2 additions & 3 deletions Admin/Get-SimpleAuditLogReport.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@ Process {
# Deal with each object in the input
$searchresults | ForEach-Object {

# Reset the result object
$Result = New-Object PSObject

# Get the alias of the User that ran the command
$user = ($_.caller.split("/"))[-1]

Expand Down Expand Up @@ -183,6 +180,8 @@ Process {
# Get just the name of the cmdlet that was run
[string]$cmdlet = $_.CmdletName

# Reset the result object
$Result = New-Object PSObject
# Build the result object to return our values
$Result | Add-Member -MemberType NoteProperty -Value $user -Name Caller
$Result | Add-Member -MemberType NoteProperty -Value $cmdlet -Name Cmdlet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Counts down 60 seconds and updates the Progress bar during the proess.

#>
Function Start-SleepWithProgress {
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '', Justification = 'Start-Sleep does not use -WhatIf')]
Param(
[Parameter(Mandatory = $true)]
[int]$SleepTime,
Expand Down
4 changes: 2 additions & 2 deletions Diagnostics/AVTester/Test-ExchAVExclusions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ param (
)

. $PSScriptRoot\..\..\Shared\Confirm-Administrator.ps1
. $PSScriptRoot\..\..\Shared\Write-SimpleLogFile.ps1
. $PSScriptRoot\..\..\Shared\Start-SleepWithProgress.ps1
. $PSScriptRoot\Write-SimpleLogFile.ps1
. $PSScriptRoot\Start-SleepWithProgress.ps1

# Log file name
$LogFile = "ExchAvExclusions.log"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', '', Justification = 'All Parameters are used in other functions of the script')]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification = 'Value is used')]
[CmdletBinding()]
Param (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#v21.01.22.2234
Function Start-JobManager {
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '', Justification = 'I prefer Start here')]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', '', Justification = 'Removed unneeded functions')]
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)][array]$ServersWithArguments,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1451,7 +1451,7 @@ Function Invoke-AnalyzerEngine {
-DisplayWriteType $shaDisplayWriteType `
-AnalyzedInformation $analyzedResults

$analyzedResultsults = Add-AnalyzedResultInformation -Name "Signature Hash Algorithm" -Details $certificate.SignatureHashAlgorithm `
$analyzedResults = Add-AnalyzedResultInformation -Name "Signature Hash Algorithm" -Details $certificate.SignatureHashAlgorithm `
-DisplayGroupingKey $keySecuritySettings `
-DisplayCustomTabNumber 2 `
-DisplayWriteType $shaDisplayWriteType `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Function Test-RequiresServerFqdn {

try {
Invoke-Command -ComputerName $Script:Server -ScriptBlock { Get-Date | Out-Null } -ErrorAction Stop
Write-Verbose "Connected successfully using: $($Script:Server)."
Write-Verbose "Connected successfully using: $($Script:Server)."
} catch {
Invoke-CatchActions
if ($tempServerName.Count -gt 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# The goal of this script is to more easily investigate issues related of Managed Availability

# Provide your feedback to ExToolsFeedback@microsoft.com

[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingInvokeExpression', '', Justification = 'Override for now')]
[cmdletbinding()]
Param([string]$pathforlogs, [switch]$Collect , [switch] $AllServers , [switch] $OnlyThisServer , [switch]$Help)

Expand All @@ -30,9 +30,18 @@ function ParseProbeResult {
Param( [String] $FilterXpath , [String] $MonitorToInvestigate , [String] $ResponderToInvestigate)

TestFileorCmd $ProbeResulteventcmd;
ParseProbeResult2 ($ProbeResulteventcmd + " -maxevents 200" ) $FilterXpath "Parsing only last 200 probe events for quicker response time" $MonitorToInvestigate $ResponderToInvestigate
if ("yes", "YES", "Y", "y" -contains (Read-Host ("`nParsed last 200 probe events for quicker response.`nDo you like to parse all probe events ? Y/N (default is ""N"")")))
{ ParseProbeResult2 $ProbeResulteventcmd $FilterXpath "Parsing all probe events. this may be slow as there is lots of events" $MonitorToInvestigate $ResponderToInvestigate }
ParseProbeResult2 -ProbeResulteventcompletecmd ($ProbeResulteventcmd + " -maxevents 200" ) `
-FilterXpath $FilterXpath `
-waitstring "Parsing only last 200 probe events for quicker response time" `
-MonitorToInvestigate $MonitorToInvestigate `
-ResponderToInvestigate $ResponderToInvestigate
if ("yes", "YES", "Y", "y" -contains (Read-Host ("`nParsed last 200 probe events for quicker response.`nDo you like to parse all probe events ? Y/N (default is ""N"")"))) {
ParseProbeResult2 -ProbeResulteventcompletecmd $ProbeResulteventcmd `
-FilterXpath $FilterXpath `
-waitstring "Parsing all probe events. this may be slow as there is lots of events" `
-MonitorToInvestigate $MonitorToInvestigate `
-ResponderToInvestigate $ResponderToInvestigate
}
}

function ParseProbeResult2 {
Expand Down Expand Up @@ -122,7 +131,7 @@ function InvestigateProbe {
if ( -not ($ProbeInfo.TargetResource -eq "[null]"))
{ $probename2add += "/" + $ProbeInfo.TargetResource }
}
if ($ProbeDetailsfullname -eq $null )
if ($null -eq $ProbeDetailsfullname)
{ $ProbeDetailsfullname = $Probename = $probename2add }
else {
$ProbeNameAlreadyinthelist = $false
Expand Down Expand Up @@ -157,13 +166,16 @@ function InvestigateProbe {
} else
{ Write-Host -ForegroundColor red ("Missing logs from path $EacBackEndLogonProbefolder ") }
} else {
ParseProbeResult ("*[UserData[EventXML[ResultName='" + $ProbeDetailsfullname + "']]]") $MonitorToInvestigate $ResponderToInvestigate
ParseProbeResult -FilterXpath ("*[UserData[EventXML[ResultName='" + $ProbeDetailsfullname + "']]]") `
-MonitorToInvestigate $MonitorToInvestigate `
-ResponderToInvestigate $ResponderToInvestigate
}
} else
{ Write-Host("`nFound no definitions for " + $ProbeToInvestigate + " probe") }
}

Function InvestigateMonitor {
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseOutputTypeCorrectly', '', Justification = 'Override for now')]
[cmdletbinding()]
Param( [String]$MonitorToInvestigate , [String]$ResourceNameToInvestigate , [String]$ResponderTargetResource , [String] $ResponderToInvestigate)

Expand Down Expand Up @@ -218,11 +230,20 @@ Function InvestigateMonitor {
if ($ProbeToInvestigate) {
if ($ProbeToInvestigate.Count -gt 1) {
Write-Host ("`nMultiple probes linked with the monitor " + $MonitorToInvestigate + " , here is the list : " + $ProbeToInvestigate)
foreach ($individualProbetoInvestigate in $ProbeToInvestigate)
{ InvestigateProbe $individualProbetoInvestigate $MonitorToInvestigate $ResponderToInvestigate $ResourceNameToInvestigate $ResponderTargetResource }
foreach ($individualProbetoInvestigate in $ProbeToInvestigate) {
InvestigateProbe -ProbeToInvestigate $individualProbetoInvestigate `
-MonitorToInvestigate $MonitorToInvestigate `
-ResponderToInvestigate $ResponderToInvestigate `
-ResourceNameToInvestigate $ResourceNameToInvestigate `
-ResponderTargetResource $ResponderTargetResource
}
} else {
Write-Host ("`nThe probe triggering " + $MonitorToInvestigate + " monitor is " + $ProbeToInvestigate)
InvestigateProbe $ProbeToInvestigate $MonitorToInvestigate $ResponderToInvestigate $ResourceNameToInvestigate $ResponderTargetResource
InvestigateProbe -ProbeToInvestigate $ProbeToInvestigate `
-MonitorToInvestigate $MonitorToInvestigate `
-ResponderToInvestigate $ResponderToInvestigate `
-ResourceNameToInvestigate $ResourceNameToInvestigate `
-ResponderTargetResource $ResponderTargetResource
}
} else
{ Write-Host ("`nFound no probe triggering " + $MonitorToInvestigate ) }
Expand Down Expand Up @@ -402,7 +423,10 @@ Function InvestigateResponder {
$MonitorToInvestigate = $ResponderDetails.AlertMask
if ($MonitorToInvestigate) {
Write-Host ("`nThe monitor triggering " + $ResponderToInvestigate + " Responder is " + $MonitorToInvestigate)
InvestigateMonitor $MonitorToInvestigate $ResourceNameToInvestigate $ResponderDetails.TargetResource $ResponderToInvestigate
InvestigateMonitor -MonitorToInvestigate $MonitorToInvestigate `
-ResourceNameToInvestigate $ResourceNameToInvestigate `
-ResponderTargetResource $ResponderDetails.TargetResource `
-ResponderToInvestigate $ResponderToInvestigate
} else
{ Write-Host ("`nFound no monitor triggering " + $ResponderToInvestigate + "`n" ) }
if ($Script:KnownIssueDetectionAlreadydone -eq $false) { KnownIssueDetection $null $ResponderToInvestigate }
Expand Down Expand Up @@ -553,7 +577,7 @@ function CheckifthiscanbeaknownissueusingMonitor {
if ($Script:lastProbeerror) {
if ($Script:lastProbeerror.Exception -like "*The underlying connection was closed*") {
Write-Host -foreground yellow "This probe error message related to underlying connection closed has been seen when connection for loopback adapter has been blocked at lower level before reaching Exchange`n"
Write-Host -foreground yellow "You can check in IIS Default Web Site /Actions pane / Bindings that All Unassigned is used and this has not been changed to only allow specific IP.`n"
Write-Host -foreground yellow "You can check in IIS Default Web Site /Actions pane / Bindings that `"All Unassigned`" is used and this has not been changed to only allow specific IP.`n"
Write-Host -foreground yellow "This has been seen when blocking some TLS version using Secureprotocols registry key or through GPO.`n"
Write-Host -foreground yellow "You can check if some TLS version are disabled under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols (https://techcommunity.microsoft.com/t5/exchange-team-blog/exchange-server-tls-guidance-part-2-enabling-tls-1-2-and/ba-p/607761).`n"
Write-Host -foreground yellow "You may also check if this is linked with antivirus or local firewall rules.`n"
Expand Down Expand Up @@ -616,16 +640,21 @@ function InvestigateUnhealthyMonitor {
Start-Sleep -s 1
$UnhealthyMonitorToInvestigate = $myHealthEntryList | Out-GridView -PassThru -Title $Selectunhealthymonitor
if ( $UnhealthyMonitorToInvestigate) {
if (([string]::Compare($UnhealthyMonitorToInvestigate.Server, $env:computername, $true) -eq 0) -or ($pathforlogsspecified))
{ InvestigateMonitor $UnhealthyMonitorToInvestigate.Name $null $UnhealthyMonitorToInvestigate.TargetResource $null }
else {
if (([string]::Compare($UnhealthyMonitorToInvestigate.Server, $env:computername, $true) -eq 0) -or ($pathforlogsspecified)) {
InvestigateMonitor -MonitorToInvestigate $UnhealthyMonitorToInvestigate.Name `
-ResourceNameToInvestigate $null `
-ResponderTargetResource $UnhealthyMonitorToInvestigate.TargetResource `
-ResponderToInvestigate $null
} else {
Write-Host -ForegroundColor yellow ("`nThe Monitor you select is regarding a different server : " + $UnhealthyMonitorToInvestigate.Server + " .")
Write-Host -ForegroundColor yellow ("Run this script on this server directly to analyse this monitor further." )
}
} else
{ Write-Host ("`nYou have not selected any unhealthy monitor. Run the script again and select an occurrence" ) }
} else
{ Write-Host ("`nFound no unhealthy monitor." ) }
} else {
Write-Host ("`nYou have not selected any unhealthy monitor. Run the script again and select an occurrence" )
}
} else {
Write-Host ("`nFound no unhealthy monitor." )
}
}

function CollectMaLogs {
Expand All @@ -645,7 +674,7 @@ function CollectMaLogs {
if (-not (Test-Path($OutputPath)))
{ New-Item -ItemType Directory -Force -Path $OutputPath | Out-Null }
if (-not (Test-Path($OutputPath)))
{ Write-Host "Failed to create " + $OutputPath + " to store logs collected"; exit }
{ Write-Host "Failed to create $OutputPath to store logs collected"; exit }

$ExchangeServerinfofile = $OutputPath + "\" + $env:computername + "_ExchangeServer_FL.TXT"
$ExchangeServerinfo | Out-File $ExchangeServerinfofile
Expand Down Expand Up @@ -685,7 +714,7 @@ function CollectMaLogs {
if (-not (Test-Path($logcollectionmonitoringfolder)))
{ New-Item -ItemType Directory -Force -Path $logcollectionmonitoringfolder | Out-Null }
if (-not (Test-Path($logcollectionmonitoringfolder)))
{ Write-Host "Failed to create " + $logcollectionmonitoringfolder + " to store logs collected"; exit }
{ Write-Host "Failed to create $logcollectionmonitoringfolder to store logs collected"; exit }

$monitoringfiles = Get-ChildItem ( $monitoringfolder.Fullname ) | Where-Object { $_.PSIsContainer -eq $false }
if ($monitoringfolder.Name -eq "ActiveMonitoringTraceLogs")
Expand All @@ -703,7 +732,7 @@ function CollectMaLogs {
if (-not (Test-Path($logHighAvailabilityfolder)))
{ New-Item -ItemType Directory -Force -Path $logHighAvailabilityfolder | Out-Null }
if (-not (Test-Path($logHighAvailabilityfolder)))
{ Write-Host "Failed to create " + $logHighAvailabilityfolder + " to store HighAvailability logs collected"; exit }
{ Write-Host "Failed to create $logHighAvailabilityfolder to store HighAvailability logs collected"; exit }
foreach ($HighAvailabilityfile in $HighAvailabilityfiles ) {
Write-Progress ("Collecting " + $HighAvailabilityfile.Fullname)
Copy-Item $HighAvailabilityfile.Fullname -Destination $logHighAvailabilityfolder
Expand Down Expand Up @@ -1146,8 +1175,19 @@ if ($Investigationchoose -eq 2) {
}
switch ( $IsitaResponderorMonitororProbe) {
0 { InvestigateResponder $SpecificResponderorMonitororProbe $null }
1 { InvestigateMonitor $SpecificResponderorMonitororProbe $null $null $null }
2 { InvestigateProbe $SpecificResponderorMonitororProbe $null $null $null $null }
1 {
InvestigateMonitor -MonitorToInvestigate $SpecificResponderorMonitororProbe `
-ResourceNameToInvestigate $null `
-ResponderTargetResource $null `
-ResponderToInvestigate $null
}
2 {
InvestigateProbe -ProbeToInvestigate $SpecificResponderorMonitororProbe `
-MonitorToInvestigate $null `
-ResponderToInvestigate $null `
-ResourceNameToInvestigate $null `
-ResponderTargetResource $null
}
}
} else
{ Write-Host -ForegroundColor red ("No name specified") }
Expand Down Expand Up @@ -1183,8 +1223,10 @@ if ($Investigationchoose -eq 4) {
InvestigateUnhealthyMonitor $ServerHealthfile
}
if ($Investigationchoose -eq 5) {
ParseProbeResult "*[UserData[EventXML [ResultType='4']]]" $null $null
ParseProbeResult -FilterXpath "*[UserData[EventXML [ResultType='4']]]" `
-MonitorToInvestigate $null `
-ResponderToInvestigate $null
}
if (($Investigationchoose -eq 6) -and ($exchangeversion)) {
CollectMaLogs $MyInvocation.MyCommand.Path
}
}
1 change: 0 additions & 1 deletion M365/src/DLT365Groupsupgrade.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ Function Debugdirsync {
}
#Check if Distribution Group can't be upgraded because EmailAddressPolicyViolated
Function Debugmatchingeap {
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', '', Justification = 'Incorrect rule result')]
param(
[Parameter(Mandatory = $true)]
[PScustomobject]$Distgroup
Expand Down
12 changes: 2 additions & 10 deletions PSScriptAnalyzerSettings.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,8 @@
IncludeDefaultRules = $true

ExcludeRules = @(
'PSAvoidUsingWriteHost'
)

IncludeRules = @(
'PSPlaceOpenBrace',
'PSPlaceCloseBrace',
'PSUseConsistentWhitespace',
'PSUseConsistentIndentation',
'PSAlignAssignmentStatement',
'PSUseCorrectCasing'
'PSAvoidUsingWriteHost',
'PSReviewUnusedParameter'
)

Rules = @{
Expand Down
1 change: 0 additions & 1 deletion Performance/ExPerfAnalyzer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# Licensed under the MIT License.

[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification = 'Vars are in use')]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', '', Justification = 'Parameters are in use')]
[CmdletBinding()]
Param(
#[Parameter(Mandatory=$true,ParameterSetName="FileDirectory")][string]$PerfmonFileDirectory,
Expand Down
Loading