update
This commit is contained in:
45
Exemples/Nagvis - generateur de carte/script.ps1
Normal file
45
Exemples/Nagvis - generateur de carte/script.ps1
Normal file
@ -0,0 +1,45 @@
|
||||
cls
|
||||
|
||||
$Folder = "C:\Users\hubert.cornet\Downloads\Centreon\maps"
|
||||
$FichierTemplate = "Mag000.cfg"
|
||||
$FichierListMag = "_liste.csv"
|
||||
|
||||
$ListeMag = Import-CSV -Path $Folder"\"$FichierListMag -Delimiter ";"
|
||||
|
||||
Foreach ($Mag in $ListeMag) {
|
||||
$Number = $Mag.Magasins.SubString(3,3)
|
||||
$TPV = $Mag.tpv.SubString(3,5)
|
||||
|
||||
$FichierMap = $Folder+"\Mag"+$Number+".cfg"
|
||||
|
||||
If (!(Test-Path -Path $FichierMap+".new") -And !(Test-Path -Path $FichierMap)) {
|
||||
Write-host "False"
|
||||
|
||||
Copy-Item $Folder"\Mag000.cfg" -Destination $FichierMap+".old"
|
||||
(Get-Content $FichierMap+".old") -Replace "Mag000", "Mag$Number" | Set-Content $FichierMap+".tmp1"
|
||||
(Get-Content $FichierMap+".tmp1") -Replace "swa-000", "swa-$Number" | Set-Content $FichierMap+".tmp2"
|
||||
|
||||
If (Test-Path -Path $FichierMap+".old") {
|
||||
Remove-Item -Path $FichierMap+".old" -Force
|
||||
}
|
||||
|
||||
(Get-Content $FichierMap+".tmp2") -Replace "AAAAA", "$TPV" | Set-Content $FichierMap+".new"
|
||||
|
||||
If (Test-Path -Path $FichierMap+".tmp1") {
|
||||
Remove-Item -Path $FichierMap+".tmp1" -Force
|
||||
}
|
||||
|
||||
If (Test-Path -Path $FichierMap+".tmp2") {
|
||||
Remove-Item -Path $FichierMap+".tmp2" -Force
|
||||
}
|
||||
}
|
||||
Else {
|
||||
Write-host "True"
|
||||
|
||||
(Get-Content $FichierMap+".new") -Replace "BBBBB", "$TPV" | Set-Content $FichierMap
|
||||
|
||||
If (Test-Path -Path $FichierMap+".new") {
|
||||
Remove-Item -Path $FichierMap+".new" -Force
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user