无法将参数绑定到参数“Path”因为它是空的。参数似乎根本不为空
检查远程计算机上是否存在文件:
#Check if Dir exists on the machine we are copying from
$dir = ($APPROD001Root + $instance + "\" + $type + "\" + $year + "\" + $monthFormatted)
Write-Host $dir
if(Test-Path -Path $dir){
Write-Host ($dir + " exists!")
$files = Get-ChildItem -Path $dir
#Check if the Dir has files in it
if($files.Length -gt 0){
#Check if the folder exists on the machine we are copying towards, if not create it!
$dirReceivingMachine = ($DBStag01Root + $instance + "\" + $type + "\" + $year + "\" + $monthFormatted)
Write-Host $dirReceivingMachine
if($dirReceivingMachine -eq $null){
Write-Host "the path is null..."
}
$folderExists = Invoke-Command -ScriptBlock { Test-Path -Path $dirReceivingMachine } -Session $session
if(!$folderExists){
Write-Host ("folder " + $dirReceivingMachine + " does not yet exist we want to create it!")
#Invoke-Command - ScriptBlock { New-Item -Path $dirReceivingMachine -ItemType Directory } -Session $session
}
设置$ folderexists始终投掷的命令命令
无法将参数与参数“路径”结合,因为它为null。 + categoryInfo:InvalidData:{:) [test-Path],parameterBindingValidationException + firmomqualifyErrid:参数argumentValidationErrornullnotlower,Microsoft.powershell.commands.testpathcommand
我在终端中获得的输出IS
d:mydata \ 2018 \ 09 D:\ mydata \ 2018 \ 09存在! D:\ mydata \ 2018 \ 09不能将参数绑定到 参数“路径”,因为它为空。 + categoryInfo:InvalidData:(:) [test-Path],parameterBindingValidationException
As you can see the Write-Host "The path is null.." never fires, so the variable I am passing into Test-Path is not null yet PS says是在调用命令的时候...
不知道为什么要这样做
Checking if a file exists on a remote machine:
#Check if Dir exists on the machine we are copying from
$dir = ($APPROD001Root + $instance + "\" + $type + "\" + $year + "\" + $monthFormatted)
Write-Host $dir
if(Test-Path -Path $dir){
Write-Host ($dir + " exists!")
$files = Get-ChildItem -Path $dir
#Check if the Dir has files in it
if($files.Length -gt 0){
#Check if the folder exists on the machine we are copying towards, if not create it!
$dirReceivingMachine = ($DBStag01Root + $instance + "\" + $type + "\" + $year + "\" + $monthFormatted)
Write-Host $dirReceivingMachine
if($dirReceivingMachine -eq $null){
Write-Host "the path is null..."
}
$folderExists = Invoke-Command -ScriptBlock { Test-Path -Path $dirReceivingMachine } -Session $session
if(!$folderExists){
Write-Host ("folder " + $dirReceivingMachine + " does not yet exist we want to create it!")
#Invoke-Command - ScriptBlock { New-Item -Path $dirReceivingMachine -ItemType Directory } -Session $session
}
The invoke-command that sets the $folderExists always throws
Cannot bind argument to parameter 'Path' because it is null.
+ CategoryInfo : InvalidData: (:) [Test-Path], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.TestPathCommand
the output I get in terminal is
D:MyData\2018\09
D:\MyData\2018\09 exists!
D:\MyData\2018\09 Cannot bind argument to
parameter 'Path' because it is null.
+ CategoryInfo : InvalidData: (:) [Test-Path], ParameterBindingValidationException
As you can see the Write-Host "The path is null.." never fires, so the variable I am passing into Test-Path is not null yet PS says it is when invoking the command...
No idea why it does this
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论