启动一个进程并允许它使用连接的网络驱动器

Start a process and allow it to use connected network drives

我正在尝试将网络共享备份到 USB 驱动器,同时存档数据。为此,我调用 7-zip 归档器(实际上我使用哪个归档器并不重要),如下所示:

new-psdrive -name O -psprovider filesystem -root '\kapital-dc01\disk_o'  -credential $cred 
$arclog=(. 'c:\program files-zipz.exe' a -bb1 -bd -bse1 -mmt6 -r -v1200m "f:\disk_o\disk_o-$timestamp.7z" 'o:\')
然而,

7-zip 在尝试从 O: 获取数据时报告 "file not found" 错误。在 Powershell 中,我可以毫无问题地 dir o:\。此脚本是 运行 通过任务管理器作为 SYSTEM 帐户的作业。我应该使用什么来启动 7-zip 并访问连接的网络驱动器?

您需要为 New-PSDrive 使用 -Persist 开关以使驱动器可用于 windows 会话,而不仅仅是 PowerShell 会话。

You can use the Persist parameter of New-PSDrive to create Windows mapped network drives. Unlike temporary Windows PowerShell drives, Windows mapped network drives are not session-specific. They are saved in Windows and they can be managed by using standard Windows tools, such as File Explorer and Net Use.

来源:MSDN