version 1

This commit is contained in:
Bruno_21
2020-05-25 10:34:53 +02:00
commit 330f4e7613
2 changed files with 100 additions and 0 deletions

81
ajt_creator/ajt2.ps1 Normal file
View File

@@ -0,0 +1,81 @@
# On efface / backup tous les fichiers MGPT*.dat existants
$fileToCheck = "$env:USERPROFILE\Desktop\MGPT*.dat"
$archivePath = "$env:USERPROFILE\Desktop\MGPT_Ajt_Archives"
if (Test-Path $fileToCheck -PathType leaf) { # leaf: file, container: folder, any: tous
Write-host $fileToCheck
#Remove-Item $fileToCheck
if (!(Test-Path $archivePath -PathType container)) {
mkdir $archivePath
}
Move-Item -Path $fileToCheck -Destination $archivePath -Force
}
# On importe le .csv selon $header
$header = "planche", "d_deb", "X", "h_deb", "h_fin", "J", "d_fin", "lieu", "VC", "gare", "zep", "encadrant", "rptx", "ncp", "get"
$A = import-csv -Path "$env:USERPROFILE\Desktop\xls\essai ve 15-05.csv" -Delimiter ";" -Header $header
# On sélectionne uniquement les lignes commençant par AK ou BF
$planches = $A | Where-Object planche -Match "^AK*|^BF*"
# Pour chaque opération
ForEach ($operation in $planches){
# Operation
$ope = $($operation.planche).Split(" ")[1]
#$ope
# ZEP/Groupement
#CCTT 8948 "ZEP DJ20948" (702+712+714+720+722+724+726+728)
$zep = $($operation.zep).Split(" ")[1]
#$zep
# Debut
$dd = $($operation.d_deb)
$y = $($dd.Split("/")[2])
$m = $($dd.Split("/")[1])
$d = $($dd.Split("/")[0])
$dd = "$($y)$($m)$($d)"
$hd = $($operation.h_deb).Replace(":", "")
$debut = "$($dd)$($hd)"
#$debut
# Fin
$df = $($operation.d_fin)
$y = $($df.Split("/")[2])
$m = $($df.Split("/")[1])
$d = $($df.Split("/")[0])
$df = "$($y)$($m)$($d)"
$hf = $($operation.h_fin).Replace(":", "")
$fin = "$($df)$($hf)"
#$fin
# Voie
$voie = ""
# Rptx
$rptx = $($operation.rptx).Split(":")[1]
#$rptx
# N° CP
$cp = $($operation.ncp)
#$cp
# Tel
$tel = "0000000000"
#$tel
# Terminaison
$term = "||||||||||||||||||||||||||"
$ligne = "$($ope)|1|$($zep)|$($voie)|$($debut)|$($fin)|$($rptx)|$($cp)|$($tel)$term"
Write-host $ligne
# Chaque opération est écrite dans le fichier MGPT_<date-du-jour>.dat
echo $ligne >> $env:USERPROFILE/Desktop/MGPT_$dd.dat
}

19
usb.ps1 Normal file
View File

@@ -0,0 +1,19 @@
$usb = GET-WMIOBJECT win32_diskdrive | Where { $_.InterfaceType -eq 'USB' }
$usb
#If ($usb.model -ne "Kingston DataTraveler 3.0 USB Device"){
If ($usb.model -eq "USB Device"){
Write-host "USB Device inserted"
}
#Register-WmiEvent -Class win32_VolumeChangeEvent -SourceIdentifier volumeChange
#$newEvent = Wait_Event -SourceIdentifier volumeChange
#$newEvent
$drives = Get-PSDrive
$drives
foreach ($root in $drives.root){
$root
}
# |{}