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!