powershell - 将文件共享路径作为参数读取时出错
问题描述
执行以下脚本时收到以下错误。
测试路径:找不到接受参数“input.dat”的位置参数。
.\FL.ps1 \\flamingdev\analytics\source\INBOUND \\flamingdev\analytics\source\OUTBOUND
[CmdletBinding()]
param (
[string] $SrcFolder,
[string] $FileListPath
)
$SrcFolder
$FileListPath
IF (Test-Path "$FileListPath"\input.dat) {
Remove-Item "$FileListPath"\input.dat
}
Get-ChildItem -File -Path "$SrcFolder"\Extract* | Select-Object - ExpandProperty Name | Add-Content -Path "$FileListPath"\input.dat
解决方案
您需要在双引号中使用“所有路径”。像这样:
IF (Test-Path "$FileListPath\input.dat") {
Remove-Item "$FileListPath\input.dat"
}
Get-ChildItem -File -Path "$SrcFolder\Extract*" | Select-Object -ExpandProperty Name | Add-Content -Path "$FileListPath\input.dat"
推荐阅读
- javascript - 如何将JSF中的对象列表传递给javascript函数
- android - HelloCordova 在我的 Android 手机上错误卸载但需要重新安装,在 CLI 中运行的 Cordova 不这样做
- javascript - 检查一个数组是否包含 JavaScript 中另一个数组的任何元素,并返回两个数组中都不存在的值
- python - Numpy 索引顺序
- makefile - 更改openwrt编译包的默认目录src
- python - 如何在 Python 中仅在特定点进行平滑样条插值设置导数?
- java - 如何查看 myBatis 真正使用的 SQL 查询?
- windows - 在 windows 中启动 mongod 服务
- node.js - 我正在查看 lambda 日志
- javascript - 更改 ngFor 的特定元素,其中列表更改