bastianusmus
Goto Top

Powershell Softwareinstallation (Ordnerabfrage)

Moin,

ich erarbeite grade für die Installation von Software(Bei dem Austausch eines Rechners) ein kleines Script.

Aktueller Stand:
Ein User hat einen Laptop und bekommt einen neuen, wegen Leasingende.
In C:\tools\flags werden Dateien angelegt, die nach den installierten Programmen benannt sind, diese werden als CSV von einem bereits vorhandenen Tool exportiert. -> Diese CSV Importiere ich im Script

Auf dem Server Tosys001 liegen mehrere Ordner mit den Installationsdateien, alle Ordner sind nach dem Programm und der Version benannt -> Das sind 7 Pfade, die Ordnerstruktur lasse ich mir als CSV exportieren, zusammenfügen und dann als eine CSV importieren.

Dann bekommt jede LINE in der CSV eine Variable - jetzt benötige ich eine Abfrage, Schleife, Was auch immer nach dem Motte: WENN $install_software_names = $csv_main_software_names, dann gehe in Ordner $install_path1 und starte $csv_main_software_names\install.exe - wenn nicht, dann zähle $csv_main_software_names hoch bis es übereinstimmt und installiert werden kann...

ich hoffe das ist verständlich xD

$home_path = '\\brdl902039564\c$\_Techbar\Softwareinstall'  
$install_paths = '\\brdl902039564\c$\_Techbar\Softwareinstall\install_paths'  
$install_path1 = '\\tosys001\InstWKS\Install_W10'  
$install_path2 = '\\tosys001\InstWKS\Install_W10_W764'  
$install_path3 = '\\tosys001\InstWKS\Install_W10_W864_W764'  
$install_path4 = '\\tosys001\InstWKS\Install_W764'  
$install_path5 = '\\tosys001\InstWKS\Install_W764_XPO7'  
$install_path6 = '\\tosys001\InstWKS\Install_W864'  
$install_path7 = '\\tosys001\InstWKS\Install_W864_W764'  

Write-Host -ForegroundColor Yellow "Software Pfade werden erstellt..."  
(Get-ChildItem -Directory $install_path1) | select Name | Export-Csv $install_paths\install_path1.csv -NoTypeInformation
(Get-ChildItem -Directory $install_path2) | select Name | Export-Csv $install_paths\install_path2.csv -NoTypeInformation
(Get-ChildItem -Directory $install_path3) | select Name | Export-Csv $install_paths\install_path3.csv -NoTypeInformation
(Get-ChildItem -Directory $install_path4) | select Name | Export-Csv $install_paths\install_path4.csv -NoTypeInformation
(Get-ChildItem -Directory $install_path5) | select Name | Export-Csv $install_paths\install_path5.csv -NoTypeInformation
(Get-ChildItem -Directory $install_path6) | select Name | Export-Csv $install_paths\install_path6.csv -NoTypeInformation
(Get-ChildItem -Directory $install_path7) | select Name | Export-Csv $install_paths\install_path7.csv -NoTypeInformation
Write-Host -ForegroundColor Green "Software Pfaden wurden unter \\BRDL902039564\c$\_Techbar\Softwareinstall\install_paths erstellt"  

# Zusammenfügen von allen .csv Dateien und exportieren als main_software.csv
$csvFileList = Get-ChildItem $install_paths -Filter install_*.csv
$csvFilesToImport = $csvFileList | Select-Object -ExpandProperty FullName
$importedCsvFiles = $csfFilesToImport | Import-Csv
$importedCsvFiles | Export-Csv $install_paths\main_software.csv -NoTypeInformation

# Flags vom alten Gerät importieren und als Variable speichern
$csv_old_flags = Import-CSV '\\brdl902039564\C$\_Techbar\Softwareinstall\flag.csv'  
$install_software_names = @()
$csv_old_flags | ForEach-Object { 
    $install_software_names += $_.Details_table0_FileName 
    }

#$($install_software_names)

# main_software importieren und als Variable speichern
$csv_main_software = Import-CSV '\\brdl902039564\C$\_Techbar\Softwareinstall\install_paths\main_software.csv'  
$csv_main_software_names = @()
$csv_main_software | ForEach-Object { 
    $csv_main_software_names += $_.Name
    }

#$($csv_main_software_names)

Content-Key: 5932857631

Url: https://administrator.de/contentid/5932857631

Printed on: June 2, 2024 at 09:06 o'clock

Member: Dirmhirn
Dirmhirn Feb 11, 2023 at 19:32:00 (UTC)
Goto Top
Hi,

Weiß nicht ob du nicht mit einem fertigen Tool besser fährst. Wieviel Geräte sind es denn?
Außerdem würde ich keine Exe dirrkt aufrufen, sondern powershell script(s), die gleich individuelle Konfig & Co übernehmen. Oder läuft das alles über die CSV?

Zu deiner Frage: Test-Path müsste dir da helfen.

Sg Dirm
Member: Crusher79
Crusher79 Feb 12, 2023 at 21:46:55 (UTC)
Goto Top
Zitat von @Dirmhirn:

Hi,

Weiß nicht ob du nicht mit einem fertigen Tool besser fährst. Wieviel Geräte sind es denn?
Außerdem würde ich keine Exe dirrkt aufrufen, sondern powershell script(s), die gleich individuelle Konfig & Co übernehmen. Oder läuft das alles über die CSV?

Zu deiner Frage: Test-Path müsste dir da helfen.

Sg Dirm

Wäre da auch eher bei https://chocolatey.org/

Auch in der kostenlosen Version meist nur 1 Zeiler. Und Pakete kann man auch selber bauen und z.B. mit Nexus hinterlegen.

Je nach Software wird unattended oder via z.B. AutoIT installiert. Das nimmt einen viel ab. Über Versionsangabe kann man auch gezielt Pakete ausklammern. Fertig.

Würde meine Energie dann liebrer in die Scripts oder die Anpassung investieren. Da du hier eh schon bei PS bist wird es dir vermutlich nicht schwer fallen. Man kann auch mit kleinen Tools anfangen.

Dann bleiben zum deployen nur die normalen Befehle: install, force-install, update etc. Fertig.

mfg Crusher