0
我想找到一種方法來替換數組變量末尾的字符..試過各種方式,並沒有運氣..這裏是我有什麼Foreach和如果狀態替換字符powershell結束
foreach ($File in $Files){
if ($File.EndsWith(".test"))
{
#Replaces test with EURTest at the end of the string
$File2 += $_ -replace "test", "EURTest"
}
elseif ($CanBeRemovedRoamingProfile.EndsWith("CTE"))
{
# Do nothing
$File2 += $File
}
else{
$File2 += $_ + '.Final'
}
}
有什麼想法嗎?
這樣做會產生什麼結果是不可取的?如何定義'$ File2'? – BACON
好吧..它似乎並沒有工作..它沒有吐出任何錯誤.. $ File2只是另一個變量(數組),將持有正確的結局的新列表 – tyson619