如何说服 powershell(通过任务调度程序运行)找到我的网络驱动器? [英] How can I convince powershell (run through task scheduler) to find my network drive?
本文介绍了如何说服 powershell(通过任务调度程序运行)找到我的网络驱动器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 Windows 7 上有一个无法正常工作的简单 powershell 脚本.(这不是 XP 上的问题)
I have a simple powershell script on windows 7 that doesn't work properly. (this is not an issue on XP)
get-psdrive
当我直接运行它时,我得到
When I run it directly, I get
Name Used (GB) Free (GB) Provider Root
---- --------- --------- -------- ----
A FileSystem A:\
Alias Alias
C 12.30 11.60 FileSystem C:\
cert Certificate \
D FileSystem D:\
Env Environment
Function Function
HKCU Registry HKEY_CURRENT_USER
HKLM Registry HKEY_LOCAL_MACHINE
**Q 1486.63 289.41 FileSystem Q:\**
Variable Variable
WSMan WSMan
当我通过任务调度程序运行它时,我得到
When I run this through task scheduler, I get
Name Used (GB) Free (GB) Provider Root
---- --------- --------- -------- ----
A FileSystem A:\
Alias Alias
C 12.30 11.60 FileSystem C:\
cert Certificate \
D FileSystem D:\
Env Environment
Function Function
HKCU Registry HKEY_CURRENT_USER
HKLM Registry HKEY_LOCAL_MACHINE
Variable Variable
WSMan WSMan
请注意,我丢失了 Q: 驱动器.如果有任何方法可以解决此问题,我将能够将文件复制到那里....
Note that I'm missing my Q: drive. If there's any way to get this resolved, I'll be able to copy files there....
推荐答案
也许在脚本中运行 get-psdrive 之前,首先做这样的事情:
Maybe before running get-psdrive in script, firstly do something like this:
$net = new-object -comobject Wscript.Network
$net.mapnetworkdrive("Q:","\\path\to\share",0,"domain\user","password")
在完成你的工作(复制文件..)之后:
and after doing your job (copying files..):
$net.removenetworkdrive("Q:")
这篇关于如何说服 powershell(通过任务调度程序运行)找到我的网络驱动器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文