-->

How to Check SMB Directory Handle Leasing in Windows 11

    How to Check SMB Directory Handle Leasing in Windows 11
    Learn how to check SMB directory handle leasing in Windows 11 using PowerShell and troubleshoot SMB directory performance.

    SMB directory handle leasing is a Windows networking feature that can help reduce repeated directory handle requests between an SMB client and server. When it is enabled, the SMB client can cache directory handles and reuse them for future requests, which can reduce network traffic and improve performance for workloads that perform many directory operations.

    Windows 11 includes PowerShell tools that make it possible to inspect SMB share properties and related server configuration. In particular, the DirectoryHandleLeasing property can be examined with Get-SmbShare, while the server-level EnableDirectoryHandleLeasing setting can be checked with Get-SmbServerConfiguration.

    This guide explains how to check SMB directory handle leasing in Windows 11, understand the difference between share-level and server-level settings, filter shares, export results, and troubleshoot unusual SMB performance behavior.

    What Is SMB Directory Handle Leasing?

    Directory handle leasing allows an SMB client to cache directory handles and reuse them for subsequent requests. Instead of repeatedly requesting a new directory handle from the SMB server, the client can reuse a cached handle when the SMB configuration and workload allow it.

    Microsoft documents the share-level DirectoryHandleLeasing property as a Boolean setting. When it is enabled, the SMB client can cache directory handles and reuse them for future requests. When disabled, the client must request a new directory handle for each request, which can increase network traffic and potentially reduce performance.

    This can matter most on systems that perform a large number of directory operations. For example, workloads involving large directory trees, applications that frequently enumerate folders, or systems accessing files over SMB can generate many directory-related requests.

    Directory Handle Leasing vs SMB Leasing

    The name can be confusing because Windows SMB has more than one type of leasing-related feature.

    DirectoryHandleLeasing specifically concerns directory handles. It should not be confused with the LeasingMode property discussed in SMB leasing and oplock configuration.

    The SMB share LeasingMode controls SMB leasing and oplock behavior for application compatibility. Microsoft documents values such as Full, Shared, and None.

    For a broader explanation of SMB leasing, see How to Check SMB Leasing in Windows 11.

    In other words:

    • DirectoryHandleLeasing: concerns caching and reuse of directory handles.
    • LeasingMode: controls SMB leasing and oplock behavior.
    • EnableDirectoryHandleLeasing: controls directory handle leasing at the SMB server configuration level.

    Why Check SMB Directory Handle Leasing?

    Checking this property can help when investigating SMB performance, application compatibility, or unexpected differences between shares.

    You may want to check it when:

    • an SMB workload performs many directory operations
    • network traffic appears higher than expected
    • two SMB shares have different performance characteristics
    • you are comparing SMB share configurations
    • you are investigating directory enumeration performance
    • you are reviewing advanced SMB server settings
    • you need to document SMB configuration before making changes

    Directory handle leasing should not be treated as a universal performance switch. SMB performance depends on many factors, including network latency, SMB dialect, Multichannel, encryption, compression, storage performance, permissions, and application behavior.

    Open PowerShell in Windows 11

    The easiest way to inspect SMB share properties is PowerShell.

    1. Press Windows + X.
    2. Select Terminal (Admin) or PowerShell (Admin).
    3. Approve the User Account Control prompt if Windows asks for permission.

    You can also open Windows Terminal normally and run the commands if the account has sufficient permissions for the information you need to inspect.

    Check SMB Directory Handle Leasing for All Shares

    Start by displaying the SMB shares and their directory handle leasing status:

    Get-SmbShare | Select-Object Name, Path, DirectoryHandleLeasing

    This produces a focused view instead of displaying every SMB share property.

    A result may look similar to this:

    Name       Path          DirectoryHandleLeasing
    ----       ----          ---------------------
    Projects   D:\Projects   True
    Public     D:\Public     False
    Archive    E:\Archive    True

    The exact output depends on the SMB shares and configuration of the computer.

    How to Interpret DirectoryHandleLeasing

    The DirectoryHandleLeasing value is Boolean-based.

    Value Meaning
    True Directory handle leasing is enabled for the share.
    False Directory handle leasing is disabled for the share.

    A True value means the SMB client can cache and reuse directory handles for the share. A False value means the client must request a new directory handle for each applicable request. Microsoft notes that disabling the feature can increase network traffic and reduce performance.

    However, the presence of True does not guarantee that every application will become faster. Actual results depend on the workload, client behavior, SMB version, storage system, and network conditions.

    Check One SMB Share

    If you only want to inspect one share, use the -Name parameter:

    Get-SmbShare -Name "Projects" | Select-Object Name, Path, DirectoryHandleLeasing

    This is useful when troubleshooting a specific network share instead of reviewing the entire SMB configuration.

    You can also display the complete object:

    Get-SmbShare -Name "Projects" | Format-List *

    The full output can contain many additional properties, so the focused Select-Object command is usually easier to read when documenting a specific setting.

    Find Shares With Directory Handle Leasing Enabled

    You can filter the results to show only shares where directory handle leasing is enabled:

    Get-SmbShare -DirectoryHandleLeasing $true |
    Select-Object Name, Path, DirectoryHandleLeasing

    To find shares where it is disabled, use:

    Get-SmbShare -DirectoryHandleLeasing $false |
    Select-Object Name, Path, DirectoryHandleLeasing

    Current Microsoft documentation lists DirectoryHandleLeasing as a filter parameter for Get-SmbShare.

    Check the SMB Server Configuration

    Share-level configuration is only part of the picture. Windows also provides a server-level setting called EnableDirectoryHandleLeasing.

    Check it with:

    Get-SmbServerConfiguration |
    Select-Object EnableDirectoryHandleLeasing

    You can display the complete SMB server configuration with:

    Get-SmbServerConfiguration | Format-List *

    Microsoft documents EnableDirectoryHandleLeasing as a server setting that enables directory handle leasing. When enabled, the server can cache directory handles for longer periods, which can improve performance for certain workloads involving large numbers of directory operations.

    Share-Level vs Server-Level Directory Handle Leasing

    This distinction is important when troubleshooting.

    Setting Cmdlet Purpose
    DirectoryHandleLeasing Get-SmbShare Inspect the directory handle leasing property associated with an SMB share.
    EnableDirectoryHandleLeasing Get-SmbServerConfiguration Inspect the SMB server's directory handle leasing configuration.

    Do not assume that checking only one property gives you a complete picture of the SMB environment. When troubleshooting advanced SMB behavior, review both the share and server configuration where appropriate.

    Check Directory Handle Leasing With Other SMB Properties

    Directory handle leasing is more useful when reviewed alongside other SMB share properties.

    For example:

    Get-SmbShare |
    Select-Object Name, Path, DirectoryHandleLeasing, LeasingMode,
    ContinuouslyAvailable, CachingMode, EncryptData, CompressData

    This lets you compare directory handle leasing with several other SMB features covered in related guides.

    For example, SMB share caching mode can affect Offline Files behavior, while SMB leasing and oplocks affect caching and application compatibility.

    See How to Check SMB Share Caching Mode in Windows 11 and How to Check SMB Opportunistic Locking (Oplocks) in Windows 11 for related configuration details.

    Check Directory Handle Leasing With SMB Server Settings

    You can also compare the directory handle leasing server setting with other SMB server features:

    Get-SmbServerConfiguration |
    Select-Object EnableDirectoryHandleLeasing,
    EnableLeasing,
    EnableOplocks,
    EnableMultiChannel,
    EnableSMB2Protocol

    This can be useful when creating a configuration inventory for a Windows 11 SMB server.

    For a broader server configuration review, see How to Check SMB Server Configuration in Windows 11.

    Export SMB Directory Handle Leasing Information

    If you are auditing several computers or documenting a troubleshooting session, you can export the results to a CSV file:

    Get-SmbShare |
    Select-Object Name, Path, DirectoryHandleLeasing |
    Export-Csv "$env:USERPROFILE\Desktop\smb-directory-leasing.csv" -NoTypeInformation

    The resulting CSV file can be opened in Microsoft Excel or another spreadsheet application.

    You can also include additional properties:

    Get-SmbShare |
    Select-Object Name, Path, DirectoryHandleLeasing, LeasingMode,
    CachingMode, EncryptData, CompressData |
    Export-Csv "$env:USERPROFILE\Desktop\smb-share-settings.csv" -NoTypeInformation

    This creates a more useful SMB configuration snapshot for comparison and troubleshooting.

    Check SMB Shares Remotely

    PowerShell can also query SMB information from a remote computer by using a CIM session when the environment and permissions allow it.

    Create a CIM session:

    $session = New-CimSession -ComputerName "FileServer01"

    Then query the SMB shares:

    Get-SmbShare -CimSession $session |
    Select-Object Name, Path, DirectoryHandleLeasing

    When finished, remove the CIM session:

    Remove-CimSession $session

    This approach is useful for administrators who need to inspect several Windows computers without opening an interactive desktop session on each system.

    How Directory Handle Leasing Relates to SMB Performance

    Directory handle leasing can reduce repeated directory handle requests. In workloads with many directory operations, this can reduce unnecessary network communication and potentially improve responsiveness.

    However, SMB performance is affected by many other variables.

    • SMB dialect: determines the negotiated SMB protocol version.
    • SMB Multichannel: can use multiple network paths or channels where supported.
    • SMB encryption: protects SMB traffic but can introduce processing overhead.
    • SMB compression: can reduce transferred data for suitable workloads.
    • Oplocks and leasing: affect file and data caching behavior.
    • Storage performance: determines how quickly the server can access files.
    • Network latency: affects request and response times.

    You can review these areas together with How to Check SMB Multichannel in Windows 11, How to Check SMB Dialect in Windows 11, and How to Check SMB Encryption in Windows 11.

    Directory Handle Leasing vs Folder Enumeration

    Directory handle leasing should also not be confused with SMB folder enumeration.

    DirectoryHandleLeasing concerns caching and reuse of directory handles. FolderEnumerationMode controls how directory contents are presented to SMB clients, including whether access-based enumeration is used.

    For information about the latter, see How to Check SMB Folder Enumeration Mode in Windows 11.

    Should You Disable Directory Handle Leasing?

    In general, do not change an advanced SMB setting simply because you see it enabled or disabled.

    Microsoft documents that disabling directory handle leasing forces the SMB client to request a new directory handle for each applicable request. This can increase network traffic and reduce performance.

    If an application has a documented compatibility requirement, follow the application's vendor guidance and test the change in a controlled environment.

    Before changing an SMB setting, record the current configuration:

    Get-SmbShare |
    Select-Object Name, Path, DirectoryHandleLeasing |
    Export-Csv "$env:USERPROFILE\Desktop\smb-before-change.csv" -NoTypeInformation

    This gives you a baseline that can be compared with the configuration after testing.

    How to Change Directory Handle Leasing

    Microsoft documents DirectoryHandleLeasing as a property that can be modified with Set-SmbShare.

    For example, the following command enables the property for a share named Projects:

    Set-SmbShare -Name "Projects" -DirectoryHandleLeasing $true

    To disable it:

    Set-SmbShare -Name "Projects" -DirectoryHandleLeasing $false

    Microsoft's current Set-SmbShare documentation lists DirectoryHandleLeasing as a Boolean parameter.

    Because this changes SMB behavior, test changes carefully. Avoid modifying production shares solely for experimentation.

    Verify a Configuration Change

    After making a change, verify the resulting property:

    Get-SmbShare -Name "Projects" |
    Select-Object Name, Path, DirectoryHandleLeasing

    You can also review the complete share configuration:

    Get-SmbShare -Name "Projects" | Format-List *

    Testing should include the application and workload that originally motivated the configuration change. A change that looks correct in PowerShell may not produce a measurable improvement for every workload.

    Troubleshooting SMB Directory Performance

    If an SMB workload is slow, directory handle leasing is only one area to investigate.

    1. Check the SMB share's DirectoryHandleLeasing value.
    2. Check the server's EnableDirectoryHandleLeasing setting.
    3. Check the SMB dialect used by active connections.
    4. Review SMB Multichannel configuration.
    5. Check SMB encryption and compression settings.
    6. Review leasing and oplock configuration.
    7. Check network latency and connectivity.
    8. Check storage performance on the SMB server.
    9. Review active SMB sessions and connections.
    10. Test the application with a controlled workload.

    For active SMB connections, see How to Check SMB Connections in Windows 11. For active sessions, see How to Check SMB Sessions in Windows 11.

    Useful PowerShell Commands

    Command Purpose
    Get-SmbShare List SMB shares.
    Get-SmbShare -DirectoryHandleLeasing $true Find shares with directory handle leasing enabled.
    Get-SmbShare -DirectoryHandleLeasing $false Find shares with directory handle leasing disabled.
    Get-SmbServerConfiguration View SMB server configuration.
    Get-SmbShare -Name "Projects" Inspect one SMB share.
    Get-SmbShare | Format-List * Display detailed share properties.
    Set-SmbShare -Name "Projects" -DirectoryHandleLeasing $true Enable directory handle leasing for a share.

    Frequently Asked Questions

    What is DirectoryHandleLeasing in Windows 11?

    DirectoryHandleLeasing is an SMB share property related to caching and reuse of directory handles. It can reduce repeated directory handle requests and network traffic for suitable workloads.

    How do I check DirectoryHandleLeasing?

    Run:

    Get-SmbShare | Select-Object Name, Path, DirectoryHandleLeasing

    What does DirectoryHandleLeasing True mean?

    It indicates that directory handle leasing is enabled for the SMB share.

    What does DirectoryHandleLeasing False mean?

    It indicates that directory handle leasing is disabled for the SMB share.

    Is DirectoryHandleLeasing the same as SMB Leasing?

    No. Directory handle leasing concerns directory handles, while the SMB LeasingMode property controls SMB leasing and oplock behavior.

    Can Directory Handle Leasing improve SMB performance?

    It can help certain workloads by allowing directory handles to be cached and reused, reducing repeated requests and network traffic. The actual performance benefit depends on the workload and environment.

    Can I change DirectoryHandleLeasing?

    Yes. Microsoft documents the DirectoryHandleLeasing Boolean parameter for Set-SmbShare. Changes should be tested carefully, particularly on production systems.

    Related SMB Guides

    Final Thoughts

    Checking SMB directory handle leasing is a useful step when investigating advanced SMB configuration and directory-related performance behavior in Windows 11.

    The key PowerShell commands are Get-SmbShare for inspecting the share-level DirectoryHandleLeasing property and Get-SmbServerConfiguration for checking the server-level EnableDirectoryHandleLeasing setting.

    Directory handle leasing should be considered together with SMB leasing, oplocks, caching, Multichannel, encryption, compression, network performance, and storage performance. Looking at these settings together provides a much more complete picture of how an SMB environment is configured.

    Before changing advanced SMB settings, document the current configuration and test the effect with the workload that matters to you. This makes troubleshooting more systematic and reduces the risk of introducing unexpected SMB compatibility or performance problems.

    LihatTutupKomentar