简体   繁体   中英

MAP DRIVE not showing in remote computer explorer

I've been scratching my head for a long. I've two Windows servers both are joined to Domain and DFS is installed. So when I'm trying to create a MAP drive remotely from server1 to server2 code is not getting an error and it is showing the drive is created but when I log on to the server2 to check, it is not showing the mapped drive. I've tried many methods but it is not working out for me when I execute the script manually to the remote server it gets created only while remote execution I'm facing the issue. This is the code I'm using

Invoke-Command -ComputerName $SecondaryServer -ScriptBlock { 
Register-PSSessionConfiguration -Name Demo -RunAsCredential 'abc.local\Administrator' -Force }

Invoke-Command -ComputerName $SecondaryServer -ScriptBlock {

 New-PSDrive -Persist -Name "T" -PSProvider "FileSystem" -Root "\\abc.local\Demo1" -ErrorAction stop
 } -ConfigurationName Demo 

The above code is not generating any error.

Try using -Scope Global.
And why using separate invoke session ! , single session would work.

Invoke-Command -ComputerName $SecondaryServer -ScriptBlock { 
Register-PSSessionConfiguration -Name Demo -RunAsCredential 'abc.local\Administrator' -Force
New-PSDrive -Persist -Name "T" -PSProvider "FileSystem" -Root "\\abc.local\Demo1" -ErrorAction stop -Scope Global
 } -ConfigurationName Demo 

Check out https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/new-psdrive?view=powershell-7.2&viewFallbackFrom=powershell-6

New-PSDrive -Persist -Name "X" -PSProvider "FileSystem" -Root "\\Server01\Public" -Scope Global

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM