Menu Sidebar

List all SPNs in Active Directory

Ran into a situation where I needed to get all the SPNs that are listed in AD.

Find duplicate SPNs

Listing duplicate SPNs is fairly easy, just use setspn -X on your command-line and you’ll find out.

What is a SPN?

An SPN or Service Principal Name is a unique identity for a service, mapped with a specific account (mostly service account). Using an SPN, you can create multiple aliases for a service mapped with a domain account.

SetSPN command-line

To set, list or delete the SPN, we use an in-built command line tool SETSPN provided by Microsoft.

Quite some scripts assume you’re looking for a specific SPN (HTTP/…), a specific user, or a specific computer. For example, using setspn to find SPNs linked to a certain computer:

Or setspn to find SPNs linked to a certain user account:

Now we need a script to list all SPNs, for all users and all computers.

Get All SPNs

SPNs are set as an attribute on the user or computer accounts. That makes it fairly easy to query for that attribute.

Powershell to the rescue!


Get All DCs in the Entire Forest

Getting a know a new environment for a new client and I a quickly needed information about all domain controllers in the entire forest.

Wrote a small little script to provide me all the information I needed:


Determine & Change Tombstone Lifetime in Active Directory

Recently, I wanted to know what the tombstone lifetime was in my environment and decided to find this using PowerShell. There are a number of ways I could do this but dong it through PowerShell would be much easier. For those of you that are new to the attribute, a good explanation of it is:

The number of days before a deleted object is removed from the directory services. This assists in removing objects from replicated servers and preventing restores from reintroducing a deleted object.

Tombstone Lifetime  is used to determine how long a deleted object in the Active Directory database (NTDS.dit) is stored. When object is deleted, it does not immediately delete from the AD database. Instead, the object as deleted is marked where the is-Deleted attribute is set to true. Additions, most attributes are removed and the object will be renamed as follows: CN=<old RDN>\0ADEL:<objectGUID>

After renaming the object is moved to the hidden Deleted Objects container. At this time, the deleted object is referred to as tombstone. Then replicates these changes to all other DCs. Only when the tombstone lifetime has been exceeded, the object is permanently removed from the AD database.

The tombstone lifetime is set with the install of the first DCs in a forest for all domains. The tombstone lifetime is not configurable per domain.

Windows 2000 (all SPs) = 60 days

Windows Server 2003 without SP = 60 days

Windows Server 2003 with SP1 = 180 days

Windows Server 2003 R2 with SP1 installed with both R2 discs = 60 days

Windows Server 2003 R2 with SP1 installed only with the first R2 Disc = 180

daysWindows Server 2003 with SP2 = 180 days

Windows Server 2003 R2 with SP2 = 180 days

Windows Server 2008 = 180 days

Windows Server 2008 R2 = 180 days

Windows Server 2012 = 180 days

Windows Server 2012 R2 = 180 days

Windows Server 2016 = 180 days

Windows Server 2019 = 180 days

More info:

AD Recycle Bin

The AD Recycle Bin enables rapid restoration of deleted objects without a restore operation by implementing two new attributes, and using two existing attributes:

  • isDeleted

    • Has existed since Windows 2000
    • Exists on every object
    • Describes if an object is deleted but restorable
  • isRecycled

    • New to Windows Server 2008 R2
    • Exists on every object once it is recycled
    • Describes if an object is deleted but not restorable
  • msDS-deletedObjectLifetime

    • New to Windows Server 2008 R2
    • Is set on the “CN=Directory Service,CN=Windows NT, CN=Services, CN=Configuration, DC=COMPANY,DC=COM” container
    • Describes how long a deleted object will be restorable
  • tombstoneLifetime

    • Has existed since Windows 2000
    • Is set on the “CN=Directory Service,CN=Windows NT, CN=Services, CN=Configuration, DC=COMPANY,DC=COM” container
    • Describes how long a deleted object will not be restorable

Basically, I wanted to know how long I had to recover  if (in my case) one of my domain controllers were down for an extended period of time. For more information on the fun that can occur if this happens and it is down beyond the tombstone lifetime, check out this article:

Determining Tombstone Lifetime:

PowerShell Code:

Upon successful execution it should return a numeric value and that’s how many days before the DC tombstones.

Did you know...
If the attribute’s value shows blank then it is setup as ‘not set’ , the tombstone lifetime of the forest is 60 days.

This happens if your enviornment has gones throught a few generations of upgrades! 🙂

Changing Tombstone Lifetime:


This same process can be leveraged to identify the msDS-deletedObjectLifetime value (180 days by default).

The tombstone lifetime of an AD forest can be modified using the ADSIEdit tool by following this procedure:

  1. At an elevated command prompt, type adsiedit.msc.
  2. Right-click ADSI Edit in the left pane and select Connect to.
  3. In the Connection Point section, select the Select a well known Naming Context radio button and select Configuration from the dropdown list.
  4. Expand Configuration; CN=Configuration,DC=<forest_root_domain>; CN=Services; and CN=Windows NT
  5. Right-click CN=Directory Service and select Properties.
  6. In the Attribute Editor tab of the properties window, locate the tombstoneLifetime attribute. The value of this attribute represents the forest’s current tombstone lifetime in days. If the attribute’s value shows <not set>, the tombstone lifetime of the forest is 60 days.
  7. To modify the tombstone lifetime, click Edit.
  8. Type the desired tombstone lifetime and click OK. Click OK again to close the properties window. The change takes effect immediately.

How to Enable or Disable Collect Activity History in Windows 10

Microsoft Windows 10 still collects activity data even when tracking is disabled., but there is a new workaround way to block it. 🙂

Starting with Windows 10 build 17040, Microsoft added settings that let you to view and manage your activity history, which Cortana uses to let you pick up where you left off. Your collected activity history allows you to jump back into what you were doing with apps, docs, or other activities, either on your PC or your phone. To resume your activities, Windows needs to collect your PC activity.

If you like, you can enable or disable letting Windows collect User Activities.

If enabled, Let Windows collect my activities will be turned on for all users, but users will still be able to turn this setting on or off for their account.
If disabled, Let Windows collect my activities will be turned off for all users, and users will not be able to turn this setting on or off for their account.

To enable or disable Activity history settings to let Windows collect User Activities for all users in Windows 10.

You must be signed in as an administrator to enable or disable online tips and help for the Settings app
Timeline requires the Windows Search service to be enabled, running, and set to Automatic (Delayed Start).


Enable or Disable Collect Activity History in Local Group Policy Editor

Local Group Policy Editor is only available in the Windows 10 Pro, Enterprise, and Education editions.

All editions can use Option TWO below.

1. Open the Local Group Policy Editor.

2. In the left pane of Local Group Policy Editor, navigate to the location below. (see screenshot below)

Computer Configuration\Administrative Templates\System\OS Policies
 In the right pane of OS Policies in Local Group Policy Editor, double click/tap on the Allow publishing of User Activities policy to edit it. (see screenshot above)

4. Do step 5 (enable) or step 6 (disable) below for what you would like to do.

 5. To Enable Collect Activity History – Select (dot) Not Configured or Enabled​ (recommended), click/tap on OK, and go to step 7 below. (see screenshot below)

NOTE: Not Configured is the default setting.
 6. To Disable Collect Activity History – Select (dot) Disabled, click/tap on OK

Enable or Disable Collect Activity History using a REG file (Workaround) 🙂

The downloadable .reg files below will add and modify the DWORD value in the registry key below.
PublishUserActivities DWORD
0 = Disable
1 = Enable
To Enable Collect Activity History
Download : Enable_Activity_history.reg
To Disable Collect Activity History
Download : Disable_Activity_history.reg
  •  Save the .reg file to your desktop.
  • Double click/tap on the downloaded .reg file to merge it.
  • When prompted, click/tap on Run, Yes (UAC), Yes, and OK to approve the merge.
  • Sign out and sign in to apply.

Convert a Dynamic IP to Static

Working on a project where on some servers the DHCP assigned addresses needs to be converted to static. Since there is always more than one…I needed to script it.

Here is a quick way to do it via PowerShell.

Hope this helps!

Oracle to charge for Java Updates & how you can disable them

Prepare for 2019

Oracle has announced that, effective January 2019, Java SE 8 public updates will no longer be available for “Business, Commercial or Production use” without a commercial license.

End of Public Updates for Oracle JDK 8

Oracle will not post further updates of Java SE 8 to its public download sites for commercial use after January 2019. Customers who need continued access to critical bug fixes and security fixes as well as general maintenance for Java SE 8 or previous versions can get long term support through Oracle Java SE Advanced Desktop, or Oracle Java SE Suite. For more information, and details on how to receive longer term support for Oracle JDK 8, please see the Oracle Java SE Support Roadmap.

Is Oracle Java still free?

The current version of Java – Java SE 9 as well as Java SE 8 – is free and available for redistribution for general purpose computing. Java SE continues to be available under the Oracle Binary Code License (BCL) free of charge. Java Runtime Environment (JRE) use for embedded devices or use of commercial features may require a license fee from Oracle. Read more about embedded use of Java SE, or contact your local Oracle sales representative to obtain a license.

What releases of Java technology are currently available?

The Java Platform, Standard Edition (Java SE) and Oracle Java SE Advanced and Suite products are currently shipping from Oracle in the form of the Java Development Kit (JDK), and Java Runtime Environment (JRE). The current releases of the software and links to older versions are available from the Java SE download page.

What are the Oracle Java licensing changes?

Due to the Oracle Java license cost changes, companies will need to collect and identify every application that is running Java SE 8 before the beginning of 2019. Doing so will ensure an accurate forecast of costs and potential non-compliance risk for future software audits in upcoming years.

What about the Java license costs?

The Oracle Technology Global Price List as of May 1, 2018 provides information about current pricing (in dollars):
Products & Metrics Named User Plus (NUP) Software Update (License & Support) Processor (Proc) Software Update (License & Support) *Note
Java SE Advanced Desktop $40 $8.80 A
Java SE Advanced $100 $22.00 $5,000 $1,100 B
Java SE Suite $300 $66.00 $15,000 $3,300 B
*Note: A: The Named User Plus minimum for this program is 2,000 NUP licenses. B: The Named User Plus minimum for this program is 10 NUP per Processor.

What should you do now?

In light of Oracle’s recent announcement, companies should begin considering:
  • How to anticipate the situation?
  • How many Java installations do we have, where and why?
  • Are there usages embedded?
  • Can we replace Java with another technology?
  • What will the cost be in January 2019?
Oracle suggests running a tool to find Java installations using a Java package called Java Usage Tracker. This will report information like:
  • The Java versions
  • Application name
  • Type (applet, command line, etc).
  • Location and more
However, the Oracle Java Usage Tracker requires a commercial license 🙂  – even though it’s included in the installer that comes with the free components.

Disabling Java Updates

Small to Medium sized organizations may not want to pay and should consider disabling updates altogether.

Windows Server 2008R2/2012/2012R2/2016 (x64)

There’s a registry setting in HKEY_LOCAL_MACHINE  that will allow you to completely disable both update notifications and the update functionality. The full path of the key is HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Update\Policy The registry entry is named EnableJavaUpdate and is a DWORD value that defaults to 1 for the update functionality to be enabled. Setting the value to 0 disables updates. When updates are enabled:

64-bit registry redirection:

There is a subkey located at HKLM\Software\Wow6432Node  that contains the relevant settings for 32-bit applications, and within here, is the expected JavaSoft registry key. This is similar to the automatic system controlled C:\Windows\SysWOW64 directory for 32-bit compatiblity. To disable updates, navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\Java Update\Policy\ Create a new DWORD value called EnableAutoUpdateCheck , and set it to 0. Change the key EnableJavaUpdate to 0; this stops any needing to install updates, and annoying prompts that non-admin users get for installing updates.

Windows Server 2003/2008 (x86)

Stop the update utility from running by deleting the key: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run\SunJavaUpdateSched Reboot the server. In rare cases the control panel needs to be opened as administrator. To do this follow the steps below: Save this as Java32_Fix.reg and run and it will fix those javacpl.exe as Administrator/Control Panel issues once and for all: Alternately, this is for 64bit OS’s running 32bit Java:

Windows (10 & 2016) Build 1709 & 1803 cannot connect to SMB Shares

Applies to: Windows 10, version 1803, Windows Server version 1803, Windows 10, version 1709, Windows Server Datacenter Core, and Windows Server Standard Core

As users and organizations are upgrading to Windows 10 Build 1709/1803 they should be aware that SMB 1.0 is no longer installed by default. Among other things, this is going to start a lot of problems especially for the networking and security departments where they might be trying to figure out if it is a firewall that is blocking or an AV program that is limiting the access to the share.

In Windows 10 Fall Creators Update (1709), and Windows Server, version 1709 (RS3) and later versions, the Server Message Block version 1 (SMBv1) network protocol is no longer installed by default. It was superseded by SMBv2 and later protocols starting in 2007. Microsoft publicly deprecated the SMBv1 protocol in 2014.

SMBv1 has the following behavior in Windows 10 Fall Creators Update and Windows Server, version 1709 (RS3):

  • SMBv1 now has both client and server sub-features that can be uninstalled separately.
  • Windows 10 Enterprise and Windows 10 Education no longer contain the SMBv1 client or server by default after a clean installation.
  • Windows Server 2016 no longer contains the SMBv1 client or server by default after a clean installation.
  • Windows 10 Home and Windows 10 Professional no longer contain the SMBv1 server by default after a clean installation.
  • Windows 10 Home and Windows 10 Professional still contain the SMBv1 client by default after a clean installation. If the SMBv1 client is not used for 15 days in total (excluding the computer being turned off), it automatically uninstalls itself.
  • In-place upgrades and Insider flights of Windows 10 Home and Windows 10 Professional do not automatically remove SMB1 initially. If the SMBv1 client or server is not used for 15 days in total (excluding the time during which the computer is off), they each automatically uninstall themselves.
  • In-place upgrades and Insider flights of Windows 10 Enterprise and Windows 10 Education do not automatically remove SMB1. An administrator must decide to uninstall SMB1 in these managed environments.
  • Automatic removal of SMB1 after 15 days is a one-time operation. If an administrator re-installs SMB1, no further attempts will be made to uninstall it.
  • The SMB version 2.02, 2.1, 3.0, 3.02, and 3.1.1 features are still fully supported and included by default as part of the SMBv2 binaries.
  • Because the Computer Browser service relies on SMBv1, the service is uninstalled if the SMBv1 client or server is uninstalled. This means that Explorer Network can no longer display Windows computers through the legacy NetBIOS datagram browsing method.
  • SMBv1 can still be reinstalled in all editions of Windows 10 and Windows Server 2016.

If you try to connect to devices that support only SMBv1, or if these devices try to connect to you, you may receive one of the following errors messages:

You can’t connect to the file share because it’s not secure. This share requires the obsolete SMB1 protocol, which is unsafe and could expose your system to attack. Your system requires SMB2 or higher. For more info on resolving this issue, see:


Older Posts

Mohammed Wasay

Dallas based Design Technologist & Hybrid Developer