【发布时间】:2021-10-28 00:01:38
【问题描述】:
我正在尝试填充脚本所在的文件路径数组。但我不想要 包含脚本路径的数组仅包含该文件夹中的其他文件。我尝试在使用列表数组填充它后将其删除,但随后我收到一个错误,即该数组是固定大小的。
#To get path in which the script is located
$mypath = $MyInvocation.MyCommand.Path
$myStringPath=$mypath.ToString().Replace("TestingScriptPath.ps1", "")
#Populates files inside the folder
$array = @()
(Get-ChildItem -Path $myStringPath ).FullName |
foreach{
$array += $_
}
#display paths
for($i = 0; $i -lt $array.length; $i++)
{
$array[$i]
}
【问题讨论】:
标签: arrays powershell arraylist