Skip to content

Commit f4eb1c8

Browse files
committed
Fix PSScriptAnalyzer alerts: replace aliases, trim trailing whitespace
1 parent 72e9a37 commit f4eb1c8

3 files changed

Lines changed: 13 additions & 13 deletions

File tree

Get-DNSDebugLog.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ function Get-DNSDebugLog
7171
{
7272
Write-Debug "PROCESS: Starting to processing File: $DNSLog"
7373

74-
getDNSLogLines -DNSLog $DNSLog | % {
74+
getDNSLogLines -DNSLog $DNSLog | ForEach-Object {
7575

7676
# Overall Total
7777
$nTotalEvaluated = $nTotalEvaluated + 1
@@ -129,6 +129,6 @@ function getDNSLogLines
129129
}
130130
elseif ($PathCorrect -eq $true)
131131
{
132-
Get-Content $DNSLog | % { $_ }
132+
Get-Content $DNSLog | ForEach-Object { $_ }
133133
}
134134
}

Write-Log-Demo.ps1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
# Demo code to illustrate using the lib/Write-Log.ps1 logging module
2-
# Based on code by Martin Norlunn:
2+
# Based on code by Martin Norlunn:
33
# https://www.norlunn.net/2020/06/07/powershell-write-log-function/
4-
#
4+
#
55
# To run:
66
# & '.\Write-Log-Demo.ps1 -Verbose'
77

88
[CmdletBinding()]
99
param ()
1010
# Cmdletbinding is required to run script with -Verbose
11-
11+
1212
# Import the log function, or declare it directly here
1313
. ".\lib\Write-Log.ps1"
14-
14+
1515
# Write an informational message
1616
Write-Log -Message "Script invoked as user: $env:USERNAME"
17-
17+
1818
# Write a warning
1919
Write-Log -Warning "This is a warning"
20-
20+
2121
# Handle errors
2222
try
2323
{

lib/Write-Log.ps1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@ function Write-Log
99
[String]$LogFolderPath = "$PSScriptRoot\Logs",
1010
[String]$LogFilePrefix = 'Log'
1111
)
12-
12+
1313
$Date = Get-Date -Format "dd_MMMM_yyyy"
1414
$Time = Get-Date -Format "HH:mm:ss.f"
1515
$LogFile = "$LogFolderPath\$LogFilePrefix`_$Date.log"
16-
16+
1717
if (-not (Test-Path -Path $LogFolderPath))
1818
{
1919
[Void](New-Item -ItemType Directory -Path $LogFolderPath -Force)
2020
}
21-
21+
2222
if (-not (Test-Path -Path $LogFile))
2323
{
2424
[Void](New-Item -ItemType File -Path $LogFile -Force)
2525
}
26-
26+
2727
$LogMessage = "[$Time] "
2828

2929
if ($PSBoundParameters.ContainsKey("ErrorObj"))
@@ -41,6 +41,6 @@ function Write-Log
4141
$LogMessage += "Info: $Message"
4242
Write-Verbose -Message $LogMessage
4343
}
44-
44+
4545
Add-Content -Path $LogFile -Value "$LogMessage"
4646
}

0 commit comments

Comments
 (0)