New-SmbGlobalMapping: A specified logon session does not exist. It may already have been terminated.

Iswarya 10 Reputation points
2024-07-24T18:34:10.1833333+00:00

Recently upgraded OS from Windows server 2019 to Windows Datacenter 2022 OS. When checking existing setups associated with mapping share drives in 2022, observed that

Getting error

New-SmbGlobalMapping: A specified logon session does not exist. It may already have been terminated.

When trying to mount Azure share drive in Windows 2022 Datacenter Server.

But, same share drive is able to be connected using New-SmbMapping command

Azure Storage Accounts
Azure Storage Accounts
Globally unique resources that provide access to data management services and serve as the parent namespace for the services.
3,223 questions
Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
13,228 questions
Azure Virtual Machine Scale Sets
Azure Virtual Machine Scale Sets
Azure compute resources that are used to create and manage groups of heterogeneous load-balanced virtual machines.
408 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Sedat SALMAN 14,065 Reputation points MVP
    2024-07-25T05:15:56.7066667+00:00

    New-SmbGlobalMapping uses double hop since it tries to create a persistent connection to your Azure file share for all users on your server. This isn't an issue with New-SmbMapping because it only establishes a connection for the current user, who has already authenticated.

    there may be some workarounds

    • Enable credential delegation for the server's computer account in Active Directory or
    • you can remove and remount
    Remove-SmbGlobalMapping -RemotePath \\<storageaccountname>.file.core.windows.net\<sharename>
    
    $cred = Get-Credential
    New-SmbGlobalMapping -RemotePath "\\storageaccountname.file.core.windows.net\sharename" -Credential $cred -Persistent $true
    
    
    
    

  2. Sumarigo-MSFT 47,021 Reputation points Microsoft Employee
    2024-07-25T09:08:39.0466667+00:00

    @Iswarya Welcome to Microsoft Q&A Forum, Thank you forposting your query here!

    Try to add localhost in front of storage account name when you add the drive. (localhost\storageaccount).
    It seems like you're encountering an issue with the New-SmbGlobalMapping command after upgrading to Windows Datacenter 2022. This error message, "A specified logon session does not exist. It may already have been terminated," can be quite frustrating, especially since the New-SmbMapping command works without any issues.

    Here are a few steps you can try to resolve this issue:

    Check Credentials: Ensure that the credentials used for New-SmbGlobalMapping are correct and have the necessary permissions to access the Azure share drive. Sometimes, the credentials might not be properly passed or recognized.

    Session Persistence: The error might be related to session persistence. Ensure that the logon session is active and hasn't been terminated. You can try re-authenticating or using a different set of credentials.

    Update Windows: Make sure your Windows Datacenter 2022 OS is up to date with the latest patches and updates. Sometimes, these updates can resolve underlying issues with commands and services.

    Use New-SmbMapping: Since New-SmbMapping works, you can use it as an alternative. However, if you specifically need New-SmbGlobalMapping, you might need to investigate further or contact Microsoft support for a more detailed resolution.

    Review Documentation: Check the official Microsoft documentation for any changes or additional requirements for using New-SmbGlobalMapping in Windows Datacenter 2022. There might be new parameters or configurations needed.

    If you continue to face issues, it might be helpful to look into the specific differences between New-SmbMapping and New-SmbGlobalMapping commands and see if there are any additional configurations required for the latter in the new OS environment.

    Here are a few steps you can try to resolve this issue:

    Check Credentials: Ensure that the credentials used for the New-SmbGlobalMapping command are correct and have the necessary permissions. You can use the Get-Credential cmdlet to gather the credentials and pass them to the New-SmbGlobalMapping command.

    Use Persistent Flag: When creating the SMB global mapping, try using the -Persistent $true flag. This ensures that the mapping persists across reboots. For example:

       $creds = Get-Credential
       New-SmbGlobalMapping -RemotePath "\\storageaccountname.file.core.windows.net\folder1" -Credential $creds -LocalPath T: -Persistent $true
    
    1. Add Localhost Prefix: Some users have found that adding localhost in front of the storage account name helps resolve the issue. For example:
       New-SmbGlobalMapping -RemotePath "\\localhost\storageaccountname.file.core.windows.net\folder1" -Credential $creds -LocalPath T:
    

    Check for Updates: Ensure that your Windows Datacenter 2022 server is up to date with the latest patches and updates. Sometimes, these updates can resolve underlying issues with the OS.

    Alternative Methods: If the issue persists, you can try using the New-SmbMapping command as a workaround, as you mentioned it works without issues.

    References

    New-SmbGlobalMapping (SmbShare) | Microsoft Learn

    Please let us know if you have any further queries. I’m happy to assist you further.    


    Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.