Unable to Map drive to workgroup machine when I'm running the script using the Invoke-command. I'm connecting to a workgroup machine using the Invoke-command and there I'm trying to map a drive. I'm able to connect to the machine but unable to Map the drive. The options below I have tried:
I have tried using
net use $driveName $ShareLocation $Password /u:$Username
Getting Error:
System error 1312 has occurred. + CategoryInfo : NotSpecified: (System error 1312 has occurred.:String) [], RemoteException + FullyQualifiedErrorId : NativeCommandError + PSComputerName : 10.125.160.132 A specified logon session does not exist. It may already have been terminated.
I have tried using
$net.MapNetworkDrive($driveName, $ShareLocation, $false, $Username, $Password);
New-PSDrive -Name K -PSProvider FileSystem -Scope Global -Root $ShareLocation -Credential $Credential -Persist
Getting Error:
A specified logon session does not exist. It may already have been terminated. + CategoryInfo : OperationStopped: (:) [], COMException + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException
This is working fine when I'm trying this code directly on the remote machine.
I have also tried enabling CredSSP on both the machine and using Invoke-command. It didn't help
Configure the policy value for Computer Configuration >> Windows Settings >> Security Settings >> Local Policies >> Security Options >> "Network access: Do not allow storage of passwords and credentials for network authentication" to "Enabled".
A specified logon session does not exist. It may already have been terminated. (Exception from HRESULT: 0x80070520) Reading around, this would suggest that the key was not marked as exportable during the import. So I set about re-importing the certificate , but to no avail.
powershell - A specified logon session does not exist. It may already have been terminated - Stack Overflow A specified logon session does not exist. It may already have been terminated
As the error implies a session error with Azure, we'd still suggest posting there to see if there are any suggestion that can help. Important This section, method, or task contains steps that tell you how to modify the registry. However, serious problems might occur if you modify the registry incorrectly.
It seems like the "double hop" problem. Try following these links to fix it: New-PsDrive Remote copy from DFS share errors: A specified logon session does not exist
https://social.technet.microsoft.com/Forums/windowsserver/en-US/a7853ac3-6c48-4615-896a-e306067ab804/net-use-via-powershell-returning-a-specified-logon-session-does-not-exist-it-may-already-have-been?forum=winserversecurity
"This behavior is by design" per the article here at Microsoft (even if the share is not for DFS) and can be resolved by changing Windows policy to allow the storing of passwords as described in the article. I've been trying to "net use" the way Bruno Bieri has, from a console app which is run periodically by Task Scheduler and the Task Scheduler Properties dialog includes a "Do not store password" checkbox; it also says "The task will only have access to local computer resources". I can't uncheck it because my organization's Windows policy doesn't allow this change.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With