Cannot access network drive in PowerShell running as administrator

前端 未结 7 1971
暗喜
暗喜 2020-12-07 13:23

I\'m running PowerShell in a Windows 7 x64 virtual machine. I have a shared folder on the host mapped as a network drive (Z:). When I run PS normally I can access that drive

7条回答
  •  北荒
    北荒 (楼主)
    2020-12-07 13:43

    One other work-around that took me ages to find is to run net use from a scheduled task as the NT AUTHORITY\SYSTEM account. Apparently drives mapped under this account show up for all users and all elevation levels.

    I've tested this and it works even on NFS shares (which can be a bit finicky). Just create a scheduled task set to run at system startup, and specify the usual command:

    net use Z: \\server\share /persistent:no
    

    It might possibly work to run it just once with /persistent:yes, but I haven't tried that. Granted, "just map it again" works too, but that drive still won't be visible to scheduled tasks running in different contexts. The downside is that all real users see it too, so not so good for multiuser setups.

提交回复
热议问题