Determine if Windows needs rebooted from commandline

The following registry queries can be used to determine if Windows needs to be rebooted.

The RebootPending value at

reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing"

The RebootRequired value at

reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update"

The PendingFileRenameOperations value at

reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager"

Putting this together in a script such as below can make it a bit quicker to test.

@echo off

REM The RebootPending value at
reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing" | find /I "RebootPending" >NUL 2>&1
if %ERRORLEVEL% == 0 ( echo ComponentBasedServicing:  RebootPending) else ( echo ComponentBasedServicing:  false )

REM The RebootRequired value at
reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update" | find /I "RebootRequired" >NUL 2>&1
if %ERRORLEVEL% == 0 ( echo WindowsUpdateAutoUpdate:  RebootRequired) else ( echo WindowsUpdateAutoUpdate:  false )

REM The PendingFileRenameOperations value at
reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager" | find /I "PendingFileRenameOperations" >NUL 2>&1
if %ERRORLEVEL% == 0 ( echo PendingFileRenameOperations:  true) else ( echo PendingFileRenameOperations:  false )

Example output from the above script on my system.

C:\scratch>check_pendingreboot.cmd
ComponentBasedServicing:  false
WindowsUpdateAutoUpdate:  false
PendingFileRenameOperations:  true

Make Apache2’s autoindex a bit more mobile-friendly

Adding the following to an .htaccess file either in each folder you have directory listing enabled (Options +Indexes), or at the root of your DocumentRoot location, you can have a bit more of a mobile-friendly directory listing presented to users on mobile devices.

IndexHeadInsert "<meta name='viewport' content='width=device-width, initial-scale=1'><meta http-equiv='X-UA-Compatible' content='IE=edge'>"

LetsEncrypt with ServiceDeskPlus

Here are my notes for using a LetsEncrypt SSL certificate with ManageEngine ServiceDesk Plus.

Generate a LetsEncrypt SSL certificate

In my environment, I’m running SDP on a Windows Server. I installed Certbot for Windows on the Windows server.

Once installed, I issued the following command on the Windows Server.

certbot certonly --standalone -d ticket.domain.com

Replace ticket.domain.com with your properly configured domain name for the LE certificate.

Generate PKCS#12 Format Certificate

To import the LetsEncrypt certificate into SDP, we need to generate a certificate file in PKCS#12 format. The .pfx file, which is in a PKCS#12 format, contains the SSL certificate (public keys) and the corresponding private keys in one file.

On my Windows Server, I already have OpenSSL installed; if you do not, you can visit Binaries – OpenSSLWiki to install it.

When LetsEncrypt installed my new SSL certificates, they were installed into C:\Program Files\Certbot\archive\ticket.domain.com\.

Open an elevated command prompt, and issue the following commands. Take note to change the ticket.domain.com to suit your specific setup.

cd "C:\Program Files\Certbot\archive\ticket.domain.com\"
openssl pkcs12 -export -out certificate.pfx -inkey privkey1.pem -in cert1.pem -certfile chain1.pem

You’ll be prompted to create a passphrase for the PFX.

Once completed, you’ll have a newly created PFX file, certificate.pfx.

Import SSL Certificate into ServiceDeskPlus

Log into ServiceDeskPlus and head to the Admin section. Use the Search feature and type in SSL. You should get a result for Import SSL Certificate. You can navigate directly to that section by going to Admin > General Settings section > Import SSL Certificate.

Here, you will select the newly created certificate.pfx and provide the passphrase you used when creating it.

If all goes accordingly, the PFX will be imported and ready to use. You must restart the ServiceDeskPlus server (not Windows) for the newly imported certificate to be used.

.muttrc

This is my personal Mutt .muttrc dotfile.

set folder="~/Maildir"
set mask="!^\\.[^.]"
set mbox="~/Maildir"
set record="+.Sent"
set postponed="+.Drafts"
set trash="+.Trash"
set spoolfile="~/Maildir"

Find files modified in Windows command line

The forfiles command exists to facilitate finding files in a given path and can be used to also find files modified by date.

forfiles /P c:\users\techish /S /D +11/01/2022

The above command would recursively (/S) search the path (/P) C:\users\techish for all files modified after the date (/D) of November 1, 2022.

Backup VMware ESXi Host

Backup using vim-cmd

To ensure that the configuration of the target ESXi host is synchronized with persistent storage, run the following command:

vim-cmd hostsvc/firmware/sync_config

To back up ESXi configuration, run this command:

vim-cmd hostsvc/firmware/backup_config

The command will produce a link for downloading the configBundle.tgz archive.

Note that you have to replace the asterisk in the provided link with your IP/FQDN. Alternatively, access the backup file in the /scratch/downloads directory, where it is stored as configBundle-HostFQDN.tgz.

Example output

~ # vim-cmd hostsvc/firmware/backup_config
Bundle can be downloaded at : http://*/downloads/52a0a904-27aa-02ad-a6d9-ad629a51b012/configBundle-ESX2.CORP.LOCAL.tgz

Restore using vim-cmd

Before taking the first step, ensure that the ESXi version, build number, and UUID of the target host match the version, build number, and UUID of the ESXi configuration that needs to be recovered.

Then, connect to the target ESXi host via SSH and put the host into maintenance mode:

esxcli system maintenanceMode set –enable yes

or

vim-cmd hostsvc/maintenance_mode_enter

Use an SCP client to copy the archive with the ESXi configuration (configBundle-xxxx.tgz) to the target ESXi host directory.

Rename the configBundle-xxxx.tgz file to configBundle.tgz:

mv /tmp/configBundle-ESX2.CORP.LOCAL.tgz /tmp/configBundle.tgz

Recover the ESXi configuration:

vim-cmd hostsvc/firmware/restore_config /tmp/configBundle.tgz

The ESXi host will restart automatically.

Exit the maintenance mode:

esxcli system maintenanceMode set –enable no

or

vim-cmd hostsvc/maintenance_mode_exit

Configuration mismatch: The virtual machine cannot be restored because the snapshot was taken with VHV enabled.

Upon migrating a VM from one ESXi host to another ESXi host, I received the following message.

Configuration mismatch: The virtual machine cannot be restored because the snapshot was taken with VHV enabled. To restore, set vhv.enable to true

Check and confirm on both hosts that /etc/vmware/config has vhv.enabled = "TRUE" in the configuration.

This modification on the mismatched host requires a reboot.

hi

Outlook 2021 – Minimize to System Tray

To minimize Outlook to the system tray when minimized, you can right-click on the Outlook icon on the taskbar and select Minimize to System Tray. On Windows 11, this option seemed to be missing. So to configure this behavior, the following registry modification can be made.

Note: This is for Outlook 2021 (16.0). You may need to adjust if you’re using Outlook 2019 (15.0) etc.

reg add HKCU\Software\Microsoft\Office\16.0\Outlook\Preferences /v MinToTray /t REG_DWORD /d 1

Todo for the site

Working on redesign using the Arke theme from Danny Cooper and modifying some of the files.

Todo

  • Fix pagination on category (/category/name/page/number) is not working – may be an issue in the logic for post dump in the archives page format (index loop / content loop)
  • Add tagging to display and wp_query logic for archives
  • Add pagination / cleanup pagination location for per post and also category/archive/search pages

Under the search function, I return all posts (posts_per_page=>-1) and on taxonomy pages I’m limiting to 15 posts per page (posts_per_page=>15)

Update 10/20/2022: I’ve moved this to a staging dev server to complete and reverted back to the default Twenty Eleven theme.