I want to change the value in TypeAdressage column in my csv if the identifiant is found when it loop but i dont know how i can do it i try .getTypeAdressage but it's doesn't work
The CSV:
Identifiant;type;Emplacement;TypeAdressage;rack;fabriquant;dateachat
srv4Q5;serveur;Q3506;Statique;R3342;;
PWIN10;ordinateur;Q3507;Statique;;DELL;2020-01-01
Q00032;ordinateur;Q3507;Statique;;DELL;2020-01-01
Q00033;ordinateur;Q3507;Statique;;LENOVO;2021-01-01
Q00033;ordinateur;Q3507;Statique;;DELL;2020-02-03
function Changer-Type {
param(
[string]$Identifiant,
[string]$TypeAdressage,
[string]$Path
)
if(-not(Test-Path $Path -PathType Leaf) -or [IO.Path]::GetExtension($Path) -ne '.csv') {
throw 'File doest not exist or is not a Csv...'
}
$computers = Import-Csv -Path $Path -Delimiter ';'
$computers | Where-Object { $_.Identifiant -eq $Identifiant } | ForEach-Object { $_.TypeAdressage = $TypeAdressage }
#write the updated $computers object array back to disk
$computers | Export-Csv -Path $Path -NoTypeInformation -Delimiter ';' -Force
}
$csvPath = 'C:\Temp\Peripherique.csv'
Changer-Type -Identifiant "Q00032" -TypeAdressage "Dynamique" -Path $csvPath
getprefix:$computers[$i].Identifiant -eq $IdentifiantImport-Csv "C:\Temp\Peripherique.csv" |Get-Membershow?$Computers |Export-Csv C:\temp\output.csvto the end of the function - do you get the expected output in that file then?