From cb640d5b444a5d2759e4c3cd62ede9cb0451a37b Mon Sep 17 00:00:00 2001 From: Adam Bertram Date: Sun, 21 Jun 2020 11:54:55 -0500 Subject: [PATCH] Update Test-PendingReboot.ps1 --- Random Stuff/Test-PendingReboot.ps1 | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Random Stuff/Test-PendingReboot.ps1 b/Random Stuff/Test-PendingReboot.ps1 index 597e16e..fc781b9 100644 --- a/Random Stuff/Test-PendingReboot.ps1 +++ b/Random Stuff/Test-PendingReboot.ps1 @@ -1,7 +1,7 @@ <#PSScriptInfo -.VERSION 1.9 +.VERSION 1.10 .GUID fe3d3698-52fc-40e8-a95c-bbc67a507ed1 @@ -52,6 +52,8 @@ param( $ErrorActionPreference = 'Stop' $scriptBlock = { + + $VerbosePreference = $using:VerbosePreference function Test-RegistryKey { [OutputType('bool')] [CmdletBinding()] @@ -123,7 +125,7 @@ $scriptBlock = { { Test-RegistryValueNotNull -Key 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager' -Value 'PendingFileRenameOperations2' } { # Added test to check first if key exists, using "ErrorAction ignore" will incorrectly return $true - 'HKLM:\SOFTWARE\Microsoft\Updates' | ?{ test-path $_ -PathType Container } | %{ + 'HKLM:\SOFTWARE\Microsoft\Updates' | Where-Object { test-path $_ -PathType Container } | ForEach-Object { (Get-ItemProperty -Path $_ -Name 'UpdateExeVolatile' | Select-Object -ExpandProperty UpdateExeVolatile) -ne 0 } } @@ -134,8 +136,8 @@ $scriptBlock = { { # Added test to check first if keys exists, if not each group will return $Null # May need to evaluate what it means if one or both of these keys do not exist - ( 'HKLM:\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName' | ?{ test-path $_ } | %{ (Get-ItemProperty -Path $_ ).ComputerName } ) -ne - ( 'HKLM:\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName' | ?{ test-path $_ } | %{ (Get-ItemProperty -Path $_ ).ComputerName } ) + ( 'HKLM:\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName' | Where-Object { test-path $_ } | %{ (Get-ItemProperty -Path $_ ).ComputerName } ) -ne + ( 'HKLM:\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName' | Where-Object { Test-Path $_ } | %{ (Get-ItemProperty -Path $_ ).ComputerName } ) } { # Added test to check first if key exists @@ -145,6 +147,7 @@ $scriptBlock = { ) foreach ($test in $tests) { + Write-Verbose "Running scriptblock: [$($test.ToString())]" if (& $test) { $true break @@ -179,4 +182,4 @@ foreach ($computer in $ComputerName) { $psRemotingSession | Remove-PSSession } } -} \ No newline at end of file +}