commit 330f4e7613bb9360bae03046474ea17d3b61fff5 Author: Bruno_21 Date: Mon May 25 10:34:53 2020 +0200 version 1 diff --git a/ajt_creator/ajt2.ps1 b/ajt_creator/ajt2.ps1 new file mode 100644 index 0000000..a40c978 --- /dev/null +++ b/ajt_creator/ajt2.ps1 @@ -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_.dat +echo $ligne >> $env:USERPROFILE/Desktop/MGPT_$dd.dat + +} \ No newline at end of file diff --git a/usb.ps1 b/usb.ps1 new file mode 100644 index 0000000..9a92269 --- /dev/null +++ b/usb.ps1 @@ -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 + } +# |{} \ No newline at end of file