0

配列変数の末尾にある文字を置き換える方法を見つけようとしています..さまざまな方法を試しましたが、うまくいきませんでした..これが私が持っているものです

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'
}
} 

何か案が ?

4

1 に答える 1

3

の...

$File2 += $_ -replace "test", "EURTest"

...と...

$File2 += $_ + '.Final'

...$_変数を操作しています。 はコマンドレット$_で使用されますが、ループ内ではループ変数を使用する必要があります。これがこの場合です。ForEach-Objectforeach$File

于 2013-09-30T15:39:56.523 に答える