SubClient Status POD5_vcprd01 POD4_vcprd01 POD15_VCPRD01_New POD11_2_vcprd01 POD11_1_vcprd01 POD12_vcprd01 POD13_vcprd01_new POD10_vcprd01_NEW
에서 문자를 제거 나는 CSV에 위의 표에서 _new
& _New
을 제거하기 위해 노력하고 있습니다. 아래 스크립트를 작성했습니다 :문자열
$report = @()
$Pod_SC = Import-csv "above table"
foreach($Podclient in $pod_sc)
{
$Client = $Podclient.Subclient
$Subclient = $Client.Substring(0,$Client.IndexOf('_N'))
$Status = $Podclient.Status
$object = New-Object -TypeName PSobject
$object | Add-Member -MemberType NoteProperty -Name "Subclient" -Value $SubClient
$object | Add-Member -MemberType NoteProperty -Name "Status" -Value $Status
$report += $object
}
하지만 작동하지 않습니다. 예상 출력은 대소 문자를 구분 당신이 함께 _New
와 _new
모두 처리 할 수있다 ireplace
를 사용하는 경우
SubClient Status POD5_vcprd01 POD4_vcprd01 POD15_VCPRD01 POD11_2_vcprd01 POD11_1_vcprd01 POD12_vcprd01 POD13_vcprd01 POD10_vcprd01
왜 당신은 그냥 ""로 대체하지 않습니다
-ireplace "_new","_old"
내 예와 같이 동일? – SPlatten'(Get-Content $ file) -replace '_new'| 세트 내용 $ 파일' –
감사합니다. 덕분에 –