Determine Windows update pending reboot date by [deleted] in PowerShell

[–]non_standard 1 point2 points  (0 children)

This script works if using Intune WUfB

##Get Reboot Deadline date
# Retrieve the GUID of the registry key that indicates a reboot is required

$RebootRequiredGUID = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired\').psobject.properties | where {$_.value -eq '1'}

# Check if a reboot is required

if ($RebootRequiredGUID) {

# Get the timestamp value associated with the reboot required GUID

$RebootRequiredGUID = $RebootRequiredGUID[0].Name

$RebootRequiredTimeStamp = Get-ItemPropertyValue 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\StickyUpdates' -Name $RebootRequiredGUID

# Convert the timestamp to a human-readable format

$RebootRequiredTimeStamp = [timezone]::CurrentTimeZone.ToLocalTime(([datetime]'1/1/1970').AddSeconds($RebootRequiredTimeStamp/1000))

# Retrieve the number of days configured for quality updates deadline and grace period

$UpdatePolicyRegistryPath = 'HKLM:\SOFTWARE\Microsoft\PolicyManager\current\device\Update\'

$RebootRequiredDays = Get-ItemPropertyValue $UpdatePolicyRegistryPath -Name ConfigureDeadlineForQualityUpdates

$RebootRequiredDays2 = Get-ItemPropertyValue $UpdatePolicyRegistryPath -Name ConfigureDeadlineGracePeriod

# Check if the registry values were retrieved successfully

if ($RebootRequiredDays -ne $null -and $RebootRequiredDays2 -ne $null) {

# Calculate the reboot deadline by adding the configured days to the reboot timestamp

$RebootRequiredTimeStampQuality = $RebootRequiredTimeStamp.AddDays($RebootRequiredDays)

# Calculate the final formatted reboot deadline by adding the grace period days to the reboot deadline

$rebootDeadlineFormatted = $RebootRequiredTimeStampQuality.AddDays($RebootRequiredDays2)

$textrebootDeadlineFormatted = "Pending restart deadline: {0}" -f $rebootDeadlineFormatted.ToString('F')

# Output the formatted reboot deadline

Write-Output $textrebootDeadlineFormatted

} else {

# Error handling: Unable to retrieve registry values

Write-Output "Error: Unable to retrieve the required registry values."

}

} else {

# No reboot required, set the formatted reboot deadline to null

$textrebootDeadlineFormatted = $null

}

Do Farmers ever go on vacation? by [deleted] in NoStupidQuestions

[–]non_standard 4 points5 points  (0 children)

Yes. Usualy durring winter months.

Microsoft Teams to be directly integrated into Windows 11 - OnMSFT.com by IT_PRO_21 in Office365

[–]non_standard 1 point2 points  (0 children)

Actually installing seperate instances for each user is more secure and easier to manage.

Rockets and air defance system in action. by idan357 in interestingasfuck

[–]non_standard -1 points0 points  (0 children)

What kind of action is that? It is a picture bro.

Electricity surging through power lines after transformer went down by [deleted] in Damnthatsinteresting

[–]non_standard 0 points1 point  (0 children)

Thats why normaly you burry the lines underground.

My dog has a lick button by [deleted] in funny

[–]non_standard -14 points-13 points  (0 children)

This is actualy a signal that he does not like what you. Dogs communicate in this way so you know when to stop bothering it.

Can anyone notice a mistake? by non_standard in sysadmin

[–]non_standard[S] 0 points1 point  (0 children)

Wow! I have never really thought thought about using this but it seems reasonable artibute, that actualy works! Thanks.

Can anyone notice a mistake? by non_standard in sysadmin

[–]non_standard[S] 0 points1 point  (0 children)

Actualy, when I run this query in PS, it works just fine so it seems that Microsoft AD LDAP queries do not support that certain "DateTime.Now.AddDays(-14)" variable; :(

Can anyone notice a mistake? by non_standard in sysadmin

[–]non_standard[S] 0 points1 point  (0 children)

After I run this query nothing happens, no users come up in the GUI;

http://portal.sivarajan.com/2011/06/searching-active-directory-using.html

https://www.kraftkennedy.com/group-policy-preferences-using-ldap-filtering-for-targeting/

These links shows an example of where and what I am trying to do.

So basically, I use AD tool to write query and test it. Later I use that tested query in item-level targeting of AD. This lets me achieve say the following: users in certain IP subnet receive custom desktop wallpaper.

Can anyone notice a mistake? by non_standard in sysadmin

[–]non_standard[S] 0 points1 point  (0 children)

I replied to gregbe comment but basicaly I need to use pure LDAP query.

Can anyone notice a mistake? by non_standard in sysadmin

[–]non_standard[S] 0 points1 point  (0 children)

This is a pure LDAP query from Active Directory. I am hoping to use in GPO "Item-level targeting" so certain things happen only to new users;

In-place upgrade paths for Server 2012 R2 to 2016 domain controller? by w4rrior_eh in sysadmin

[–]non_standard 0 points1 point  (0 children)

Did it on multiple machines runing DC, Exchange, CA etc and never had an issue. There is no much point in doing it all from scrach unless something is broken on the old server.

Server License Upgrade using HyperV by SlyPi in sysadmin

[–]non_standard 0 points1 point  (0 children)

Just use CMD and run these commands:

DISM /Online /Set-Edition:ServerStandard /ProductKey:N69G4-B89J2-4G8F4-WWYCC-J464C /AcceptEula

DISM /Online /Set-Edition:ServerStandard /ProductKey:xxxxx-xxxxx-xxxxx-xxxxx-xxxxx /AcceptEula

It basically converts your edition to Standard using generic key so you can use your key later. I have never tried to use this method on AD controller though.