Skip to content

Commit

Permalink
Update Test-PendingReboot.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
adbertram authored Jun 21, 2020
1 parent e846680 commit cb640d5
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions Random Stuff/Test-PendingReboot.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

<#PSScriptInfo
.VERSION 1.9
.VERSION 1.10
.GUID fe3d3698-52fc-40e8-a95c-bbc67a507ed1
Expand Down Expand Up @@ -52,6 +52,8 @@ param(
$ErrorActionPreference = 'Stop'

$scriptBlock = {

$VerbosePreference = $using:VerbosePreference
function Test-RegistryKey {
[OutputType('bool')]
[CmdletBinding()]
Expand Down Expand Up @@ -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
}
}
Expand All @@ -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
Expand All @@ -145,6 +147,7 @@ $scriptBlock = {
)

foreach ($test in $tests) {
Write-Verbose "Running scriptblock: [$($test.ToString())]"
if (& $test) {
$true
break
Expand Down Expand Up @@ -179,4 +182,4 @@ foreach ($computer in $ComputerName) {
$psRemotingSession | Remove-PSSession
}
}
}
}

0 comments on commit cb640d5

Please sign in to comment.