powershell - Get-Childitem 找不到驱动器。名为“X”的驱动器不存在
问题描述
我正在编写一个脚本来使用文件资源管理器中的映射驱动器使用 powershell 复制文件。它有上述错误信息。这是它的样子:
function CopyFileToFolderUNC($SourcePath, $DestinationPath){
$temp1 = Get-ChildItem -Path $SourcePath -Recurse -Force #this is the line of error message
Copy-Item -Path $SourcePath -Destination $DestinationPath #source:\* -Destination target #watch out for login boxes when test this
}
#start here
$tempSource = "X:\Credentialing\FORMS"
$ToLocation = "C:\Users\me\Documents\2018\powershellFiles\toLoc"
CopyFileToFolderUNC $tempSource $ToLocation
它在 Copy-Item 行上具有相同的错误消息(如果我注释掉 Get-ChildItem 行),但在此之前它在 Get-ChildItem 中失败。 如何让它使用运行脚本的计算机上的映射驱动器?我在笔记本电脑上运行这个。
我在命令行的 powershell 中设置了执行策略 RemoteSigned。
当我在命令行的 powershell 中运行 Get-PSSessionConfiguration 时,我拥有此权限:
权限:NT AUTHORITY\INTERACTIVE AccessAllowed、BUILTIN\Administrators AccessAllowed、BUILTIN\Remote Management Users AccessAllowed
我以管理员身份运行。Powershell 提示符是:
[DBG]:PS C:\WINDOWS\system32>>
$PSVersionTable.PSVersion:
Major Minor Build Revision
----- ----- ----- --------
5 1 16299 666
我查看了powershell 映射驱动器 E,但他们在服务器上使用映射驱动器,所以我不确定他们在示例中需要做什么。
解决方案
推荐阅读
- spring - Spring/Swagger 下载 docx 文件生成损坏的文档
- css - 浏览器是否优化了屏幕外无限循环的 CSS 动画?
- aws-lambda - 为什么我不能在 aws_lambda_alias routing_config 中使用 aws_lambda_function 数据源?
- php - 用于 php 后端和 JS 前端的 NGINX 配置
- sql - 如何仅在 Sql 查询中为第一行填充列中的数据
- c# - 为什么这个文本字段可以正确发送数据,但它被接收为 Null 并且 Visual Studio 引发异常?
- python - 调用 Windows API 时如何使用 Python 字符串
- jekyll - 向 jekyll hyde 博客添加标签
- css - 如何将宽度设置为当前路由器插座的 100%?
- c# - 如何首先在两个表 asp.core 代码之间建立关系