【问题标题】:Creating Subdirectory With Date As Today(mm-dd-yyyy) in Network Drive [duplicate]在网络驱动器中创建日期为今天的子目录(mm-dd-yyyy)[重复]
【发布时间】:2019-11-01 05:46:10
【问题描述】:

我很难将子目录嵌套在共享网络驱动器的当前目录中。 我可以创建文件夹

Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. All rights reserved.

PS C:\Windows\system32> new-item

cmdlet New-Item at command pipeline position 1
Supply values for the following parameters:
Path[0]: C:\Temp\Powershell\Date
Path[1]:
Type: directory


    Directory: C:\Temp\Powershell


Mode                LastWriteTime     Length Name
----                -------------     ------ ----
d----        06/18/2019  10:31 AM            Date


PS C:\Windows\system32> new-item

cmdlet New-Item at command pipeline position 1
Supply values for the following parameters:
Path[0]: U:\gebersole\Documents\New Placements\UI
Path[1]:
New-Item : Cannot find drive. A drive with the name 'U' does not exist.
At line:1 char:9
+ new-item <<<<
    + CategoryInfo          : ObjectNotFound: (U:String) [New-Item], DriveNotFoundException
    + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.NewItemCommand

PS C:\Windows\system32>

【问题讨论】:

  • 您是否以管理员身份运行会话?听起来类似于this issue
  • 可以是UAC related
  • 我以管理员身份运行它,但没有运气......
  • 看来 PowerShell 会话无法看到您的“U:\”驱动器。一个简单的检查方法是 cd 到该驱动器。如果这不起作用,您可以输入net use,它应该会列出可用的驱动器。
  • 我通过在路径的每一段使用 \\ 解决了这个问题。当我测试路径时它不起作用的原因是它以 New PS U:\> Test-Path U:\gebersole\Documents\'New Placements'\CDENTAL True PS U:\> new-item 结尾

标签: powershell


【解决方案1】:

默认情况下,网络驱动器在提升的进程中不可用。你可以在这里找到更多信息:https://support.microsoft.com/en-gb/help/3035277/mapped-drives-are-not-available-from-an-elevated-prompt-when-uac-is-co

我会推荐解决方法 2。在网络驱动器上运行 net useNew-PsDrive,或者在没有提升的情况下运行脚本。

【讨论】:

  • 很奇怪,但它没有找到驱动器状态本地远程网络------------------------------ ------------------------------------------------- 不可用L: \\10.0.0.6\qsoft Microsoft Windows 网络不可用 Q: \\nllxqlaw\lxqlaw Microsoft Windows 网络不可用 R: \\nlfps01\legal Microsoft Windows 网络不可用 S: \\nlfps01\public Microsoft Windows 网络 命令成功完成。
  • PS C:\Windows\system32> cd "U:\" 设置位置:找不到驱动器。名为“U”的驱动器不存在。在 line:1 char:3 + cd cd U:\ Set-Location : 找不到驱动器。名为“U”的驱动器不存在。在 line:1 char:3
  • 这并不奇怪;这是设计使然。如果您配置EnableLinkedConnections 注册表值,无论您是否提升权限,都可以看到映射的驱动器。
【解决方案2】:

我在尝试使用映射驱动器时遇到了类似的问题,现在只对文件路径使用 UNC 格式。

不使用U:\gebersole\Documents\New Placements\UI,使用UNC 格式\\host-name\share-name\file_path 可能会起作用,在您的情况下类似于\\gebersole\Documents\New_Placements

https://www.lifewire.com/unc-universal-naming-convention-818230

【讨论】:

  • 所以主机名实际上是 \\nlfps01 并且路径是 gebersole\Documents\New Placements\UI 我在管理员计算机上找到了驱动器,但即使我尝试在管理员上 cd 它也找不到这个驱动器真的很烦人。
  • 当我使用 net use 时,它​​给了我,但 nlfps01\it 不是我要创建的子目录所在的目录.. STUMPED Status Local Remote Network OK Q: \\nllxqlaw\lxqlaw Microsoft Windows网络正常 R: \\nlfps01\legal Microsoft Windows 网络正常 S: \\nlfps01\public Microsoft Windows 网络正常 T: \\server2\timeclock Microsoft Windows 网络正常 U: \\nlfps01\it Microsoft Windows 网络
  • @AJG 如果您在普通用户帐户上运行 PowerShell,您可以访问驱动器吗?就像您在普通 PowerShell(无管理员)上执行 Test-Path \\nlfps01\your\path\here 一样,它是否有效?我有类似的问题,管理员没有看到网络驱动器,这是因为以管理员身份运行不会从您的普通帐户转移任何权限。
  • 不是来自我的帐户,但我可以访问创建驱动器的帐户,但它映射到不正确的文件夹。我需要它映射到 \\nlfps01\gebersole 但它映射到 \\nlfps01\it ....
猜你喜欢
  • 1970-01-01
  • 2021-09-25
  • 2015-12-06
  • 1970-01-01
  • 1970-01-01
  • 2016-03-13
  • 1970-01-01
  • 1970-01-01
  • 2013-03-18
相关资源
最近更新 更多