映射到SharePoint文件夹时的名称驱动器

问题描述

我有一个批处理文件,它将为当前用户有权使用的所有SharePoint位置创建一个映射驱动器。一切正常。除了一件事。

驱动器显示为 “(站点名称)x:” 它以以下格式显示: “文件夹名称(完整的UNC路径)驱动器号”。 当然,除非单击它,否则您在“此PC”中看到的所有内容都是路径的一部分。

我意识到这是一个非常微小的细节,任何具有计算机知识的人都可以重命名它们以缩短它们。只需在驱动器上单击鼠标右键即可完成此操作。我与许多不了解最基本技能的老年人一起工作。

我想在创建时定义其标签,或者在创建它的同一批次中对其重命名。

这是详细信息。 我们没有本地AD。我们不使用Intune。在你们全都跳到为什么之前,这归结为公司的所有者和他的愿望。这意味着没有GPO,也没有直接来自服务器的任何东西。必须通过远程访问命令提示符,远程PowerShell或物理坐在计算机前,一次完成所有操作。 我知道这不是做事的最有效方法。再次,所有者的偏好,出乎我的意料。

所有映射的文件夹都是每个页面通道顶部的“文件”选项卡。 每个频道的访问权限均由网站所有者/经理控制。 这样可以立即取消访问权限。

我的批次: 在IExplorer中填充受信任的站点 设置当前用户以自动登录 然后,按用户有权访问的SharePoint中的所有文件夹进行映射。

我用来映射驱动器的线已切断并干燥。

 net use W: "\\contesso.sharepoint.com\teams\<site name>\Shared Documents\<Folder Name>  /p:yes

当然,这不能解决我的问题。所以我尝试使用PowerShell

我的PowerShell脚本:

该脚本正在进行中,因为最终我会为每个站点名称,地址和驱动器号添加CSV。我需要它在可用站点列表中循环并映射允许的站点。这是脚本。

# Self-elevate the script if required
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
 if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
  $CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments
  Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
  Exit
 }
}

#Import Registry file that is located in the same folder as this script.
Reg import .\TrustedSites.reg

#Variable
$SiteName = "Folder Name"
$LibraryPath = "\\<contesso>.sharepoint.com\teams\<Site NAme>\Shared%20Documents\<Folder Name>"
$DriveID = "0:" 

#Map Path as Network Drive
$Network = new-object -ComObject WScript.Network
$Network.MapNetworkDrive($DriveID,$LibraryPath)

#Rename Mapped Drive to OurSites
$sh=New_Object -com Shell.Application
$sh.NameSpace($DriveID).Self.Name = $SiteName

不幸的是,我从PowerShell中收到一些我难以克服的错误。仍在学习如何在服务器较少的环境中使用PowerShell。

指定的设备名称无效。 在E:\ OneDrive-MHR Brands \ Desktop \ Map \ New folder \ Create_OurSites.PS1:20 char:1

  • $ Network.MapNetworkDrive($ DriveID,$ LibraryPath)
  •   + CategoryInfo          : OperationStopped: (:) [],COMException
      + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException
    
    

New_Object:术语“ New_Object”不能识别为cmdlet,函数,脚本文件或可运行程序的名称。检查名称的拼写,或者是否包含路径,请验证 路径正确,然后重试。 在E:\ OneDrive-MHR Brands \ Desktop \ Map \ New folder \ Create_OurSites.PS1:23 char:5

  • $ sh = New_Object -com Shell.Application
  • ~~~~~~~~~~
    
    • CategoryInfo:ObjectNotFound:(New_Object:String)[],CommandNotFoundException
    • FullyQualifiedErrorId:CommandNotFoundException

您不能在空值表达式上调用方法。 在E:\ OneDrive-MHR Brands \ Desktop \ Map \ New folder \ Create_OurSites.PS1:24 char:1

  • $ sh.NameSpace($ DriveID).Self.Name = $ SiteName
  •   + CategoryInfo          : InvalidOperation: (:) [],RuntimeException
      + FullyQualifiedErrorId : InvokeMethodOnNull>
    
    
    

有人知道如何通过批处理脚本,配置脚本或PowerShell脚本实现我想要的东西吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...