Skip to content

Commit 391ab85

Browse files
committed
Improve code quality and disable unnecessary warnings
1 parent 2030cd0 commit 391ab85

File tree

5 files changed

+12
-5
lines changed

5 files changed

+12
-5
lines changed

Eject-Drive.ps1

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
.SYNOPSIS
33
Eject a disk such as a USB drive safely.
44
.LINK
5+
https://superuser.com/questions/1750399/eject-dismount-a-drive-using-powershell
56
https://serverfault.com/a/580298
67
https://community.spiceworks.com/topic/2120667-how-to-safely-remove-usb-key-in-windows-server-core?page=1#entry-7617376
7-
.PARAMETER Name
8-
Drive letter
8+
.PARAMETER DriveLetter
9+
Drive letter, e.g. C
910
#>
1011

12+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingWMICmdlet", "Get-WmiObject", Justification="Used on purpose since the WMI object does not have the proper methods")]
1113
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "DriveLetter", Justification="Set to null on purpose")]
1214
param(
1315
[Parameter(Mandatory=$true)][char]$DriveLetter
@@ -17,7 +19,9 @@ param(
1719
# $driveEject = New-Object -comObject Shell.Application
1820
# $driveEject.Namespace(17).ParseName("${DriveLetter}:").InvokeVerb("Eject")
1921

20-
# Todo: replace WMI with CIM
22+
# WMI should be replaced with CIM
23+
# when a solution is found for calling the proper ejection methdods on the CIM object.
24+
# $vol = Get-CimInstance Win32_Volume | Where-Object {$_.Name -eq "${DriveLetter}:\"}
2125
$vol = Get-WmiObject -Class Win32_Volume | Where-Object {$_.Name -eq "${DriveLetter}:\"}
2226
$vol.DriveLetter = $null
2327
$vol.Put()

Install-Software.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,7 @@ function CreateTable {
617617
.LINK
618618
https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.datagridview
619619
#>
620+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidAssignmentToAutomaticVariable", "sender", Justification="Probably used by library code")]
620621
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "e", Justification="Probably used by library code")]
621622
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "sender", Justification="Probably used by library code")]
622623
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "Form", Justification="Reserved for future use")]

Report.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
Only create the archive from existing reports. This is useful if you have generated additional reports after this script.
88
#>
99

10+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSReviewUnusedParameter", "Elevated", Justification="Used in utils")]
1011
param(
1112
[switch]$Elevated,
1213
[switch]$NoArchive

Setup-Syncthing.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ choco install syncthing -y
2020
$Domain = Get-ADDomain
2121
$AccountName = "svc-$("${env:ComputerName}".ToLower())-sync"
2222
$AccountFullName = "$($Domain.NetBIOSName)\${AccountName}"
23-
echo "Using account name: ${AccountName}"
23+
Show-Output "Using account name: ${AccountName}"
2424

2525
try {
2626
# Get-LocalUser "Syncthing"

Utils.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ function Get-InstalledSoftware {
220220
#>
221221
[OutputType([System.Array])]
222222
param()
223-
if ($script:InstalledSoftware -eq $null) {
223+
if ($null -eq $script:InstalledSoftware) {
224224
Show-Information "Getting the list of installed software. This may take a while."
225225
$script:InstalledSoftware = Get-CimInstance -ClassName Win32_Product
226226
}
@@ -336,6 +336,7 @@ function Install-Executable {
336336
}
337337

338338
function Install-FromUri {
339+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingBrokenHashAlgorithms", "", Justification="Legacy MD5 support is on purpose for backwards compatibility")]
339340
[OutputType([int])]
340341
param(
341342
[Parameter(mandatory=$true)][string]$Name,

0 commit comments

Comments
 (0)