Logging geändert.
This commit is contained in:
34
install.ps1
34
install.ps1
@@ -1,27 +1,12 @@
|
||||
## Fragt nach Admin Rechten.
|
||||
# Log starten
|
||||
Start-Transcript -Path $HOME/.winconfig/run.log
|
||||
## Fragt nach Admin Rechten.
|
||||
if (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
|
||||
$arguments = "& '" + $myinvocation.mycommand.definition + "'"
|
||||
Start-Process powershell -Verb runAs -ArgumentList $arguments
|
||||
Break
|
||||
}
|
||||
|
||||
## Prüfen ob das Loggin Modul installiert ist
|
||||
if (Get-Module -ListAvailable -Name Logging) {
|
||||
}
|
||||
else {
|
||||
Write-Host "Erster Start des Scripts erkannt." -ForegroundColor Red -BackgroundColor Yellow
|
||||
Write-Host "Installiere Logging Modul" -ForegroundColor Red
|
||||
Install-Module -Name Logging -Force
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
## Setze das default Log Level
|
||||
Set-LoggingDefaultLevel -Level 'WARNING'
|
||||
Add-LoggingTarget -Name Console
|
||||
Add-LoggingTarget -Name File -Configuration @{Path = 'run.log'}
|
||||
|
||||
|
||||
# Konfig für die prompts
|
||||
$choices = New-Object Collections.ObjectModel.Collection[Management.Automation.Host.ChoiceDescription]
|
||||
@@ -60,26 +45,22 @@ do {
|
||||
$selection = Read-Host "Bitte Aufgabe auswählen"
|
||||
switch ($selection) {
|
||||
'1' {
|
||||
foreach ($utility in $toRemove) {
|
||||
Write-Log -Level 'INFO' -Message 'Versuche Paket {0} zu deinstallieren' -Arguments $utility
|
||||
foreach ($utility in $toRemove) {
|
||||
Try {
|
||||
winget uninstall --id $utility
|
||||
Write-Log -Level 'INFO' -Message 'Paket {0} erfolgreich deinstalliert.' -Arguments $utility
|
||||
winget uninstall --id $utility
|
||||
}
|
||||
Catch {
|
||||
Write-Log -Level 'WARN' -Message 'Paket {0} konnte nicht deinstalliert werden.' -Arguments $utility
|
||||
Write-Log -Level 'WARN' -Message '$_.Exception.Message' -Arguments $utility
|
||||
Write-Host "Paket $utility konnte nicht deinstalliert werden. " -ForegroundColor red
|
||||
}
|
||||
}
|
||||
} '2' {
|
||||
# Winget config installieren
|
||||
if (-not(Test-Path -Path '~\AppData\Local\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json' -PathType leaf)){
|
||||
New-Item -Path "~\AppData\Local\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json" -ItemType SymbolicLink -Value "~/.winconfig/configs/winget/settings.json"
|
||||
New-Item -Path "~\AppData\Local\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json" -ItemType SymbolicLink -Value "~/.winconfig/configs/winget/settings.json" | Out-Null
|
||||
}
|
||||
else {
|
||||
Remove-Item "~\AppData\Local\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json"
|
||||
New-Item -Path "~\AppData\Local\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json" -ItemType SymbolicLink -Value "~/.winconfig/configs/winget/settings.json"
|
||||
New-Item -Path "~\AppData\Local\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json" -ItemType SymbolicLink -Value "~/.winconfig/configs/winget/settings.json" | Out-Null
|
||||
}
|
||||
# Crap deinstallieren
|
||||
foreach ($utility in $toInstall) {
|
||||
@@ -170,3 +151,4 @@ do {
|
||||
pause
|
||||
}
|
||||
until ($selection -eq 'q')
|
||||
Stop-Transcript
|
||||
Reference in New Issue
Block a user