Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
带有配置脚本的PowerShell_Powershell - Fatal编程技术网

带有配置脚本的PowerShell

带有配置脚本的PowerShell,powershell,Powershell,需要一些帮助。我们使用配置脚本运行PowerShell脚本 e、 g..\folderA\theConfiguration脚本。\script完成所有工作。ps1 问题是,在scriptThatDoesAllTheWork.ps1所在的目录中,还有许多其他脚本 如果我不小心在scriptThatDoesAllTheWork.ps1之前添加了一个空格,则会执行该文件夹中的所有脚本 e、 g..\folderA\theConfiguration脚本 .\script这不起作用。ps1 因此,fold

需要一些帮助。我们使用配置脚本运行PowerShell脚本

e、 g..\folderA\theConfiguration脚本。\script完成所有工作。ps1

问题是,在scriptThatDoesAllTheWork.ps1所在的目录中,还有许多其他脚本

如果我不小心在scriptThatDoesAllTheWork.ps1之前添加了一个空格,则会执行该文件夹中的所有脚本

e、 g..\folderA\theConfiguration脚本 .\script这不起作用。ps1

因此,folderA\Configuration脚本中定义的所有变量都可用于执行所有工作的脚本。ps1执行所有工作

有没有办法避免这种行为


提前谢谢

谢谢mclayton。我有一个get-childitem,它将返回所有文件以防出现空间。如果这有助于任何人

如何解析配置脚本的参数?我的蜘蛛感觉告诉我,您正在
配置脚本
中使用
Get ChildItem
,第一个参数用作查找要运行的目标脚本的路径,然后运行所有匹配的项目。当您在没有空格的情况下调用它时,它实际上是在执行
Get ChildItem“\scriptthat做所有的工作.ps1”
,但是在有空格的情况下,它被视为两个参数,第一个用作路径,相当于
Get ChildItem”
返回文件夹中的所有文件。您可以将参数括在引号中,例如
\folderA\TheConfigurationScript.“\scriptthatthesallthework.ps1”
捕获输入错误或在配置脚本中添加一些错误处理,以防止它在发现多个文件时运行。请编辑问题并包括配置脚本的相关部分。问题可能在参数解析中,但没有任何代码,只是猜测而已。@mclayton。完全正确我很久以前就有一个get childitem,这就是为什么我不记得了。谢谢给小费