我正在使用脚本来保持映射的网络连接处于活动状态,但当我注销时,映射的连接当然会消失。现在的重点是,我在 Windows Server 2008 R2 上运行它,我使用远程桌面登录管理员帐户。但是,它应该保持登录状态并且不会删除映射的连接,因为此脚本负责处理 MS Office 365 Sharepoint 上的不注销问题。
有没有办法在注销后保持映射的网络位置 (L:) 可用?这样脚本就可以运行以保持连接?
# Create an IE Object and navigate to my SharePoint Site
$ie = New-Object -ComObject InternetExplorer.Application
$ie.navigate('https://xxx.sharepoint.com/')
# Don't need the object anymore, so let's close it to free up some memory
$ie.Quit()
# Just in case there was a problem with the web client service
# I am going to stop and start it, you could potentially remove this
# part if you want. I like it just because it takes out a step of
# troubleshooting if I'm having problems.
Stop-Service WebClient
Start-Service WebClient
# We are going to set the $Drive variable here, this is just
# going to tell the command what drive letter to map you can
# change this to whatever you want (if you change it to a
# drive that is already mapped it will overwrite it, so be careful.
$Drive = "L:"
# You can change the drive destiniation to whatever you want,
# it has to be a document library or folder of course.
$DrvDest = "https://xxx.sharepoint.com/files/"
# Here is where we create the object to map the network drive and
# then map the network drive
$net = New-Object -ComObject WScript.Network;
$net.mapnetworkdrive($Drive,$DrvDest)
# That is the end of the script, now schedule this with task
# scheduler and every so often and you should be set.
答案1
为什么不简单地使用资源的 UNC 路径,而不是试图保持网络驱动器打开。例如
\\服务器\文件夹
代替
左:
答案2
首先你应该学会如何:
在 Windows 资源管理器中打开 SharePoint 文档库
然后你可以创建一个批处理文件,净使用命令你将配置要验证哪个用户,并可以为所需的共享文件夹设置用户和密码
NET USE
[devicename | *] [\\computername\sharename[\volume] [password | *]]
[/USER:[domainname\]username]
[/USER:[dotted domain name\]username]
[/USER:[username@dotted domain name]
[/SMARTCARD]
[/SAVECRED]
[[/DELETE] | [/PERSISTENT:{YES | NO}]]
NET USE {devicename | *} [password | *] /HOME
NET USE [/PERSISTENT:{YES | NO}]
if you need , you can map administrator shared folders that always hide for other users