Friday, October 09, 2026

List Computers That Logged into the Domain in the Past 60 Days

 The script below will need to run from a domain controller.  Run this in PowerShell as Administrator or in Terminal as Admin.

$Cutoff = (Get-Date).AddDays(-30)


Get-ADComputer -Filter 'Enabled -eq $true' `

    -Properties LastLogonDate,OperatingSystem,DNSHostName |

    Where-Object {

        $_.LastLogonDate -ge $Cutoff -and

        $_.OperatingSystem -like "*Windows*" -and

        $_.OperatingSystem -notlike "*Server*"

    } |

    Select-Object Name,DNSHostName,OperatingSystem,LastLogonDate |

    Sort-Object LastLogonDate -Descending |

    Format-Table -AutoSize


If you'd like to export this to CSV to work with it many way, run this command and it will export it to .csv.  Just make sure the C:\Temp folder exists first.

$Cutoff = (Get-Date).AddDays(-30)


Get-ADComputer -Filter 'Enabled -eq $true' `

    -Properties LastLogonDate,OperatingSystem,DNSHostName |

    Where-Object {

        $_.LastLogonDate -ge $Cutoff -and

        $_.OperatingSystem -like "*Windows*" -and

        $_.OperatingSystem -notlike "*Server*"

    } |

    Select-Object Name,DNSHostName,OperatingSystem,LastLogonDate |

    Sort-Object Name |

    Export-Csv "C:\Temp\AD-ActiveWorkstations-30Days.csv" -NoTypeInformation


Important distinction: LastLogonDate is based on the replicated lastLogonTimestamp attribute. It helps with inventory comparisons but can lag actual logons by about 9–14 days under default AD settings. It also represents computer-account activity, not necessarily an interactive user sign-in.


Monday, October 05, 2026

How to Remove a Stale DHCP Server from Active Directory

When a Windows DHCP server is retired or removed improperly, its authorization can remain in Active Directory. This stale entry may continue to appear in the DHCP management console and should be cleaned up.

1. Check Authorized DHCP Servers

From an elevated PowerShell session on a domain controller or management system with the DHCP tools installed, run:

Get-DhcpServerInDC

You may see something similar to:

DnsName              IPAddress
-------              ---------
DHCP01.contoso.local 10.10.10.20
OLD-DHCP.contoso.local 10.10.10.15

Confirm that the server you intend to remove is actually retired and no longer providing DHCP services.

2. Remove the Stale Authorization

Remove the old DHCP server from Active Directory:

Remove-DhcpServerInDC -DnsName "OLD-DHCP.contoso.local" -IPAddress 10.10.10.15

Confirm the operation when prompted.

3. Verify the Removal

Run the following again:

Get-DhcpServerInDC

The retired server should no longer appear in the list of authorized DHCP servers.

Optional: Clean Up the DHCP Management Console

If the retired server still appears in the DHCP MMC console, right-click DHCP and select Manage Authorized Servers or remove the old server from the console.

Final Check

Removing a stale DHCP authorization does not delete DHCP scopes or modify another DHCP server. It removes the retired server's authorization record from Active Directory.

Before removing anything, verify the server name and IP address carefully—especially in environments where DHCP services have recently been migrated to a replacement server.

Friday, March 27, 2026

Migrating NPS Settings from Old Domain Controller to New Domain Controller

If you're using RADIUS on your Windows network, and you need to do Domain Controller upgrades, rebuilding RADIUS can be a pain if there are a lot of entries.  Using this process, you can easily back it up and then restore it on the new server.

NOTE:  This process assumes you are using the same name and IP address on the new OS for your new DC.

1.  Backup NPS on the old server.  Run this command:

netsh nps export filename="C:\NPS-Export.xml" exportPSK=YES

2.  For good measure, backup DHCP as well.

netsh dhcp server export C:\dhcp.txt all

3.  Copy these two files to a place where you can access them on your new DC.

4.  Once your new OS is promoted to a Domain Controller with the same name and IP address as the old DC, you can begin the import process.

5.  Install NPS on the new DC.

Install-WindowsFeature NPAS -IncludeManagementTools

6.  Import your NPS configuration file

netsh nps import filename="C:\NPS-Export.xml"

7.  Register NPS in AD

netsh ras add registeredserver

8.  Restart the NPS service

net stop ias

net start ias

PRO TIP:  Just in case, it's a good idea to grab a backup of the NPS registry key.  I personally haven't had to use it but it can't hurt to have it.

reg export HKLM\SYSTEM\CurrentControlSet\Services\IAS C:\NPS-Registry.reg

That's really all there is to it.  Good luck!

Monday, May 12, 2025

Exchange Anonymous Connector

 If you're like most, you need an internal relay on your Exchange server to allow devices and applications inside to send email without the need for credentials.  Since the connector can be scoped to the IP address of the source, this is a pretty good way to set it up.

I ran into a new issue on our new Exchange server today.  When you create the new Internal Relay receive connector to allow anonymous access, you must run a PowerShell command to make the connector accept messages.  This assumes you have the correct IP addresses in the relay.

Run this first:

Get-ADPermission "YourConnectorName" |

Where-Object { $_.User -like "NT AUTHORITY\ANONYMOUS LOGON" -and $_.ExtendedRights -like "*SMTP-Accept-Any-Recipient*" }

If this returns nothing, and it probably will, run this command to add the permissions:

Get-ReceiveConnector "YourConnectorName" |

Add-ADPermission -User "NT AUTHORITY\ANONYMOUS LOGON" `

-ExtendedRights "Ms-Exch-SMTP-Accept-Any-Recipient"

Good luck!

Monday, June 03, 2024

Can't Remove Old Exchange UCC Certificate - Certificate Bound to Send Connector

I've been running into this a lot lately where an old certificate can't be removed from Exchange as it is bound to a send connector and most commonly it's on a hybrid-mode Exchange configuration.

Here's how to get rid of it easily on Exchange and then delete the old certificate.

First, run the command to get the certificates on the Exchange server.:

Get-ExchangeCertificate | fl

This will return a full list of all certificates on the server.  Make a note of the Thumbprint of the certificate you want to keep.  That's the only one needed.

Now, shut off the "Microsoft Exchange Transport" service using Exchange PowerShell:

net stop "Microsoft Exchange Transport" or Stop-Service -Name MSExchangeTransport whichever you prefer.

Next is to get the name of your Send Connector shown in the error when trying to remove the certificate.  You'll need that name in the next command to remove any certificates that are bound to the connector:

Set-SendConnector -Identity "Outbound to Office 365 - 5c10806d-35cb-6645-8b8f-fde431830769" -TlsCertificateName $Null

At this point you can now delete the old certificate(s) as they're no longer bound to the connector.

Now run these two commands to set the variables for the certificate you want to keep.  This is where having the Thumbprint for the new certificate is needed.

$cert = Get-ExchangeCertificate -Thumbprint 6B6CB53DF162724D4F3AD97E508C5BBF072DCE8

$tlscertificatename = "<i>$($cert.Issuer)<s>$($cert.Subject)"

Do not change the syntax on the 2nd command.  That's used to pickup that variable for the final command.

Use this command finally to assign the new certificate only to the Send Connector:

Set-SendConnector -Identity "Outbound to Office 365 - 5c10806d-35cb-6645-8b8f-fde431830769" -TlsCertificateName $tlscertificatename

Finally, restart the Microsoft Exchange Transport service and you're finished.

net start "Microsoft Exchange Transport" or Start-Service -Name MSExchangeTransport

This completes the removal of any old certificates bound to the Send Connector so you can delete them from the server.  As a precaution, always test your mail flow service to make sure everything is working properly.

Good luck!


Monday, April 29, 2024

 Tonight I was trying to fully clear our older MSA 2040 SAN, which is getting a new storage lease, to life.  To my surprise, when I tried to clear the volumes and vDisks off this SAN, I found one disk group that had been quarantined, and the GUI wouldn't let me remove it, no matter what process I tried.  This MSA isn't under warranty, and there was no way to contact HPE support for help. HPE forums always finished with "contact support" and "I can't share the special commands in a forum".  Beyond frustrating.

Just a note: the MSA family is a rebrand of Dot Hill (now Seagate) AssuredSAN. Lenovo and Dell both have the same products. It's the same CLI in the Lenovo at least.

To force a disk deletion:

From CLI, create a new user with the role of "diagnostic"

# show users (to verify existing user accounts and roles)

# create user <new username> role diagnostic

The admin will be immediately prompted for a new password; use a complex password (one special character, one number, A-Z, a-z)

Verify the new user has been created by entering “show users” CLI command

After the new user account is created, log into the A controller CLI using the new diagnostic user account.

From CLI prompt, enter the "show disk-groups" command to verify disk-groups and to identify the foreign disk group you want to remove. Unfortunately, your existing disk group and the foreign disk group have the same name, capacity and RAID version so your approach to removing based upon SN is the best way to specify the appropriate disk-group for deletion.

From CLI, enter the following command:

# set advanced-settings virtual-pool-delete-override on

User will be prompted, enter “yes”

Enter “show advanced-settings” to confirm the configuration successfully entered:

The user should see “Virtual Pool Delete Override: Enabled” near the bottom of the list; it appears only when enabled.

After entering the above command to enable virtual-pool-delete-override, you will only have 15 minutes to complete delete operations; otherwise, you will need to re-enable it under the diagnostic user and continue where you left off.

After enabling virtual-pool-delete-override, continue attempting to remove the disk group using the SN approach you previously tried.

Get the vdisk or disk-group serial number if you don't have it.  When running the "show disk-group" command, the serial shows as the very long hex number.

Execute removal:

# remove disk-groups diskgroupserialnumer or

# remove vdisks diskgroupserialnumer

Restart both controllers (MC and SC).

# restart mc both

#restart sc both

This was done on an HPE MSA 2040, with storage firmware GL220P008-01. This process worked perfectly for me and allowed me to fully clear and recover all disks in the SAN.  What was only 6TB before this process is now allowing me to use the full 11TB after configuring the new disk groups and volumes.

Credits: https://forums.lenovo.com/t5/Enterprise-Storage/S2200-3200-dequrantine-diskgroup/m-p/3682552

Hard to believe a Lenovo post helped me resolve this issue on an HPE 2040 SAN.

Friday, March 29, 2024

Entra ID Set User Account Password to Never Expire

 I ran into this one recently as a user account for Cisco CUC had been created in Entra ID only and not on-premise and allowed to sync.  It's just a few PS commands and you can set the password to never expire.

NOTE:  You must be a global admin or password administrator to perform these changes.

I ran all of these commands from an Exchange 2019 on-premise server running in hybrid mode.

1. Connect to Exchange Online

Connect-ExchangeOnline

2. Connect to Microsoft Graph PowerShell and to the required scopes.

Connect-MgGraph -Scopes "User.ReadWrite.All","Group.ReadWrite.All"

3. To check a user's account to see if the password expiration is set run this command: 

Get-MGuser -UserId <user id or UPN> -Property UserPrincipalName, PasswordPolicies | Select-object UserPrincipalName,@{N="PasswordNeverExpires";E={$_.PasswordPolicies -contains "DisablePasswordExpiration"}}

4. To set the password of one user to never expire, run this command:

Update-MgUser -UserId <user ID> -PasswordPolicies DisablePasswordExpiration


These commands will allow you to set the password policy to never expire for just a single user account as needed.  For more details on how to change it for all users and check for all users, you can reference the official Microsoft Learn article HERE.

Good luck!





Wednesday, March 27, 2024

"The namespace cannot be queried. Access is denied" error when you try to create a domain-based DFS namespace

Working on setting up a new DFS Namespace today.  Ran directly into this issue.  When you sign in to Windows by using an account that belongs to the Domain Admins group, and then you try to create a domain-based namespace on any Distributed File System (DFS) namespace server, the operation fails. Windows returns an error message that resembles the following:

\\domainname.com\Public The namespace cannot be queried. Access is denied.

However, when this error occurs, you can still successfully create a standalone namespace.

The fix is to remove your account from the Protected Users group.

If you're curious, here's why it doesn't work:  When you create a new domain-based namespace, the computer queries the Domain Name System (DNS) server for domain information. The DNS server responds by sending a list of the A records of the domain controllers for that domain. The computer then contacts one of the domain controllers and tries to use your account credentials to authenticate by using NTLM authentication.

If your account belongs to the Protected Users group, your account can't use NTLM authentication. In this situation, authentication fails and generates a STATUS_ACCOUNT_RESTRICTION error.

Thursday, July 06, 2023

Is Port 80 Needed for On-Premise Exchange?

 Simply put...NO! 

Now if you go digging you will see the official Microsoft documentation stating that it is needed for failback for some HTTPS services.  From a security standpoint if the HTTPS services aren't working then I will refuse to go back to an unencrypted service just to keep it working.

Some will say if you're keeping Exchange patched and updated then having port 80 open to Exchange is no big deal.  While that may be true why risk it?

I had a customer recently that was asking why their Exchange server was showing C&C callbacks being blocked from the outside, why are there other items being blocked from the outside.  Each thing in the endpoint protection logs showed this server was being attacked on port 80.

I connected to their Cisco ASA and disabled the rule allowing port 80 to the Exchange server.  Guess what, a week went by with no further attacks being blocked.  Even though the endpoint protection was stopping them, it would only be a matter of time before an exploit is found via port 80 and then there goes the server's security posture.

I don't see a need to expose this port in 2023 on the modern Internet with all of the risks we already face daily.

Just be smart and disable port 80.  If your application won't work without it then it's time to update the application or get one that is more focused on security.  Don't compromise your network security to accommodate old software.

My $.02.  

Good luck!

Thursday, April 20, 2023

Start All Exchange Services Automatically

One Command to Rule Them All!

Little joke there....this command will start all Exchange services on a server in the event they do not start automatically as they should after a restart.

Get-Service -DisplayName "Microsoft Exchange*" | Where-Object {$_.Starttype -eq "Automatic" -and $_.Status -ne "Running"} | Start-Service

The process waits for each service to start before moving to the next one.  Really handy when you've got a lot going on and don't want to start them all by hand.

Good luck!

Friday, January 20, 2023

How to Configure a Startup Script to Map a Network Printer

A Windows startup script can be used to map a network printer at logon. Here is an example of a simple script that maps a network printer using the "net use" command:

net use LPT1: \\printserver\printer /persistent:yes

This script maps the network printer located at "\printserver\printer" to the local LPT1 port, and the "/persistent:yes" flag ensures that the mapping will remain after a reboot.

You can also use the rundll32 printui.dll,PrintUIEntry command to map network printers at logon. Here is an example of the command to map a network printer with IP address 192.168.1.100 and share name printer:

rundll32 printui.dll,PrintUIEntry /in /n\\192.168.1.100\printer

You can also use a batch file that contains the above commands, and then schedule it to run at startup using the Task Scheduler.

It is important to note that you need to have the necessary permissions to map the network printer and that the printer should be shared and available on the network.

Thursday, August 25, 2022

ADFS Web Proxy Service Won't Start

 I've seen lots of articles across the web on this.  Here's a fast way to get this fixed so you can move on to other things.  Sadly, I hit this too often when renewing certificates on ADFS servers.

NOTE:  This does not require a server restart.

Source: https://blogs.technet.microsoft.com/rmilne/2015/04/20/adfs-2012-r2-web-application-proxy-re-establis.... 

1)      Launch regedit.

2)      Navigate to HKLM\Software\Microsoft\ADFS\ProxyConfigurationStatus.

3)      Change ProxyConfigurationStatus from “2” (configured) to “1” (not configured).

4)      Launch the Remote Access Manager snap-in.

5)      Select Web Application Proxy.

6)      Select Run the Web Application Proxy Configuration Wizard.

7)      During the wizard it will prompt you to select a certificate. Select the certificate you were using before. Enter in some Domain Admin credentials (I don't think they're saved? Just used to authenticate?). Finish the config wizard.

9)      Web Application Proxy now works again.


Works for me every time.  Good luck!


Saturday, July 23, 2022

Upgrade to ESXi 7.x: Missing dependencies VIBs Error

I have been getting this error frequently lately while doing upgrades from ESXi 6.5 and 6.7 to 7.x regardless of the hardware vendor.    

If you add an upgrade baseline to the cluster or host, and you try to remediate the host, the task fails with a dependency error. When taking a closer look into the tasks details, you were getting told that the task has failed because of a failed dependency, but not which VIB it caused.


You can find the name if the causing VIB on the update manager tab of the host that you tried to update. The status of the baseline is “incompatible”, and not “non-compliant”.


To resolve this issue you have to remove the causing VIB. This is no big deal and can be done with esxcli. Enable SSH and open an SSH connection to the host. Then remove the VIB.


You need to reboot the host after the removal of the VIB. Then you can proceed with the update. The status of the upgrade baseline should be now “not-compliant”.  Just start the upgrade again and it will complete properly provided there are no other issues.

Good luck!










Friday, February 04, 2022

Fixing Windows Updates Failed with Error 0x80244022

 If you have a workstation failed to Windows Update with the error 0x80244022 from a WSUS, the fix is pretty simple and straightforward.

The reason why the error occurs is because the Application Pool that runs the WSUS service stopped.

Go to the WSUS server and open IIS Manager. Click Application Pools, select WsusPool and click Start to restart the Application Pool.


This takes care of it the bulk of the time.

Good luck!



Monday, January 10, 2022

Mount ISO in Windows Server

 I ran into an interesting issue today.  Windows Server 2012 R2 had no options to mount an ISO file.  I tried a couple of 3rd party programs to do it but they would not work either.  I found a command that can be used with PowerShell to mount an ISO and it worked perfectly.  Here's the text of the command.

Good luck!

Mount-DiskImage -ImagePath 'D:\Path\To\Image.iso' -StorageType ISO -PassThru | Get-Volume


Thursday, June 10, 2021

How to Enable or Disable the News and Interests Taskbar Windows 10

The latest updates to Windows 10 has now enabled the News and Interests taskbar by the clock on Windows 10.  Right away this started generating questions from staff on what it is or why it was turned on.   Again Microsoft pushes something out that you may not want running.

Since the GPO ADMX for it doesn't seem to be working on Windows 10 Professional, here is a quick command you can run that will make an immediate registry change and turn it off.

reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Feeds" /v ShellFeedsTaskbarViewMode /t REG_DWORD /d 2 /f

This fully hides it.  If however you want it back on change the DWORD value.  Enter 0 (show icon and text) or 1 (show icon only).


Monday, November 09, 2020

Disk Management and Explorer Show Different Drive Size

 I ran into this issue today when trying to extend out the drive size on a data drive on our primary file server.  After expanding the virtual disk in VMware, I brought up computer management (compmgmt.exe if you want to go command line quicker).

I expanded out the disk and immediately noticed that explorer didn't reflect that change after a refresh.  Also, disk management could no longer access the disk to make any edits.  I restarted the virtual disk service with no success.  A restart also proved futile.

MAKE A BACKUP BEFORE RUNNING THESE COMMANDS!

After some quick research, here is the fix.  Use DISKPART from an elevated command prompt.  Just follow the commands below and choose the proper disk on your VM.  After running the command, a quick refresh of explorer now shows the correct size.

Good luck!




Tuesday, October 13, 2020

vCenter 6.7 Resizing Disk Fails Invalid Operation for Device 0

 This one has been around for some time but now due to the data drive on my Exchange server getting closer and closer to full, I had to find a fix and here it is.  So simple and yet so hard to find on the web.

Checking the D: drive on the Exchange server showed the disk had a size of 150.254450347GB.  This disk had been restored from Datto at some point in the past and since that date this was the size showing.

Whenever attempting to expand the drive vCenter thew this error:  Invalid operation for device '0'.

I tried different sizes from adding just a few gigs to going all the way up to 200GB but getting the same error.

Ready for the fix?  You won't believe how easy it was.

1. Log into vCenter using the flex (Flash) client instead of the HTML 5 client.

2. Resize your disk successfully.


THAT'S IT!!  Can you believe it?  After all of these articles I read about changing the parameters on the VMX file, cloning the server, etc. etc. it turned out to be the behavior of the HTML 5 client.  Let's hope VMware fixes this in the next versions of vCenter before they fully remove the Flash functionality.

Good luck!

Tuesday, September 08, 2020

Fix Cisco ASDM Windows 10 Error "This app can't run on your PC"

 Seems that Microsoft has done some switching of how the Windows Scripting Host path is found.

This is a simple fix.

1. Install ASDM as you normally would

2. Right click on the shortcut.

3. In the "Target" line you will see a very long path to wscript.exe.  Simply change this path to C:\Windows\System32\wscript.exe (leave the invisible.vbs run.bat on the end as these scripts are used to open ASDM).

4. Apply the change.

After doing this I was able to open ASDM normally and use it to update ASDM and AnyConnect files on my ASA.

Good luck!

Tuesday, June 09, 2020

Exchange Logging: Clear out the log files

Here is a simple PowerShell script that you can run against Exchange either manually as part of your maintenance routine or with Task Scheduler to clear out files when you need to.

I must admit the first time I ran this on my Exchange 2013 server it took almost 5 minutes to complete and freed up over 30G of drive space from the multiple years of log files hidden all over.

At the top of the script make sure you change the drive letter if needed to match where your Exchange log files are stored.  Sadly I have seen many Exchange servers over the years with everything installed on C: so this script just assumes that.

NOTE:  Please make sure you have good backups in place and/or a snapshot of your virtual machine before running this.  While I have tested the script with no negative effects, please do not assume this will always be the case.  There is no substitution for good backups and a quick recovery plan if needed.

If you want to run the file manually, just open PowerShell as administrator, navigate to where you have your script file saved (Example Name:  ClearFiles.ps1).  From there just type in ./ClearFiles.ps1 and wait on the script to complete the cleanup.

Good luck.

Set-Executionpolicy RemoteSigned
$days=2
$IISLogPath="C:\inetpub\logs\LogFiles\"
$ExchangeLoggingPath="C:\Program Files\Microsoft\Exchange Server\V15\Logging\"
$ETLLoggingPath="C:\Program Files\Microsoft\Exchange Server\V15\Bin\Search\Ceres\Diagnostics\ETLTraces\"
$ETLLoggingPath2="C:\Program Files\Microsoft\Exchange Server\V15\Bin\Search\Ceres\Diagnostics\Logs"
Function CleanLogfiles($TargetFolder)
{
    if (Test-Path $TargetFolder) {
        $Now = Get-Date
        $LastWrite = $Now.AddDays(-$days)
        $Files = Get-ChildItem $TargetFolder -Include *.log,*.blg, *.etl, *.txt -Recurse | Where {$_.LastWriteTime -le "$LastWrite"}
        foreach ($File in $Files)
            {Write-Host "Deleting file $File" -ForegroundColor "white"; Remove-Item $File -ErrorAction SilentlyContinue | out-null}
       }
Else {
    Write-Host "The folder $TargetFolder doesn't exist! Check the folder path!" -ForegroundColor "white"
    }
}
CleanLogfiles($IISLogPath)
CleanLogfiles($ExchangeLoggingPath)
CleanLogfiles($ETLLoggingPath)
CleanLogfiles($ETLLoggingPath2)