Possible Bug: Mapping persistent drives with New-PSDrive using WINRM sessions
I am trying to map persistent drives using New-PSDrive on a remote winrm session, but when I opened a new session the mapping driver got the status of "Unavailable". I am using CREDSSP
Session A creating the mapping
$credentials = Get-Credential user
$session = New-PSSession -ComputerName Server1 -Credential $credentials -Authentication CredSSP
$computername = "Server2"
Invoke-Command -Session $session -ScriptBlock {
param($computername)
New-PSDrive -PSProvider FileSystem -Name "X" -Root "\$computername\scripts" -Persist -Verbose -Scope Global
} -ArgumentList $computername
Session B checking the mapping
$credentials = Get-Credential user
$session = New-PSSession -ComputerName Server1 -Credential $credentials -Authentication CredSSP
$computername = "Server2"
Invoke-Command -Session $session -ScriptBlock {
get-PSDrive
net use
}
Session B return:
Status Local Remote Network
Unavailable X: \Server2\scripts Microsoft Windows Network
The command completed successfully.
Am I doing something wrong?
or this is not possible?
