正如标题所说,如果我尝试添加-persist到 cmdlt,它会返回一个错误:
New-PSDrive : The network resource type is not correct
At line:1 char:1
+ New-PSDrive -Name P -Root <redacted> ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (P:PSDriveInfo) [New-PSDrive], Win32Exception
+ FullyQualifiedErrorId : CouldNotMapNetworkDrive,Microsoft.PowerShell.Commands.NewPSDriveCommand
作为参考,这是 PowerShell 中的管理员会话,但如果我在常规用户会话中执行此操作,我会得到完全相同的响应:
PS> $PSVersionTable.psversion
Major Minor Build Revision
----- ----- ----- --------
5 1 16299 666
Run Code Online (Sandbox Code Playgroud)
从一开始:我验证我要使用的驱动器号是否可用(在本例中为 P)
PS> get-psdrive
Name Used (GB) Free (GB) Provider Root CurrentLocation
---- --------- --------- -------- ---- ---------------
Alias Alias
C 36.80 22.11 FileSystem C:\ windows\system32
Cert …Run Code Online (Sandbox Code Playgroud) powershell windows-scripting drive-mapping powershell-v5.1 new-psdrive