Update aus Menü entfernt.
This commit is contained in:
152
install.ps1
152
install.ps1
@@ -51,7 +51,6 @@ function Show-Menu {
|
|||||||
Write-Host "2: Installiere Software"
|
Write-Host "2: Installiere Software"
|
||||||
Write-Host "3: Installiere optionale Software"
|
Write-Host "3: Installiere optionale Software"
|
||||||
Write-Host "4: Konfiguriere Windows"
|
Write-Host "4: Konfiguriere Windows"
|
||||||
Write-Host "5: Update System"
|
|
||||||
Write-Host "Q: Beenden"
|
Write-Host "Q: Beenden"
|
||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
@@ -130,157 +129,6 @@ do {
|
|||||||
Read-Host "Bitte das Terminal / Powershell neu starten damit Winfetch funktioniert."
|
Read-Host "Bitte das Terminal / Powershell neu starten damit Winfetch funktioniert."
|
||||||
|
|
||||||
}
|
}
|
||||||
} '5' {
|
|
||||||
Write-Host "Beginne mit dem Update aller Pakete..."
|
|
||||||
winget upgrade --all
|
|
||||||
remove-item ~\Desktop* -include *.lnk
|
|
||||||
if (Get-Module -ListAvailable -Name PSWindowsUpdate) {
|
|
||||||
Write-Host "Installiere Windows Updates..."
|
|
||||||
Install-WindowsUpdate -MicrosoftUpdate -AcceptAll -IgnoreReboot
|
|
||||||
Write-Host "Update aller Powershell Module..."
|
|
||||||
if ($SimulationMode) {
|
|
||||||
Write-Host -ForegroundColor yellow 'Simulation mode is ON, nothing will be installed / removed / updated'
|
|
||||||
}
|
|
||||||
Write-Host -ForegroundColor Cyan 'Get all PowerShell modules'
|
|
||||||
function Remove-OldPowerShellModules {
|
|
||||||
param (
|
|
||||||
[string]$ModuleName,
|
|
||||||
[string]$GalleryVersion
|
|
||||||
)
|
|
||||||
|
|
||||||
try {
|
|
||||||
$oldVersions = Get-InstalledModule -Name $ModuleName -AllVersions -ErrorAction Stop | Where-Object { $_.Version -ne $GalleryVersion }
|
|
||||||
|
|
||||||
foreach ($oldVersion in $oldVersions) {
|
|
||||||
Write-Host -ForegroundColor Cyan "$ModuleName - Uninstall previous version ($($oldVersion.Version))"
|
|
||||||
if (-not($SimulationMode)) {
|
|
||||||
Remove-Module $ModuleName -ErrorAction SilentlyContinue
|
|
||||||
Uninstall-Module $oldVersion -Force -ErrorAction Stop
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
Write-Warning "$module - $($_.Exception.Message)"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($IncludedModules) {
|
|
||||||
$modules = Get-InstalledModule | Where-Object { $IncludedModules -contains $_.Name }
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$modules = Get-InstalledModule
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($module in $modules.Name) {
|
|
||||||
if ($ExcludedModules -contains $module) {
|
|
||||||
Write-Host -ForegroundColor Yellow "Module $module is excluded from the update process"
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
elseif ($module -like "$excludedModules") {
|
|
||||||
Write-Host -ForegroundColor Yellow "Module $module is excluded from the update process (match $excludeModules)"
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
$currentVersion = $null
|
|
||||||
|
|
||||||
try {
|
|
||||||
$currentVersion = (Get-InstalledModule -Name $module -AllVersions -ErrorAction Stop).Version
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
Write-Warning "$module - $($_.Exception.Message)"
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
$moduleGalleryInfo = Find-Module -Name $module -ErrorAction Stop
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
Write-Warning "$module not found in the PowerShell Gallery. $($_.Exception.Message)"
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($null -eq $currentVersion) {
|
|
||||||
Write-Host -ForegroundColor Cyan "$module - Install from PowerShellGallery version $($moduleGalleryInfo.Version) - Release date: $($moduleGalleryInfo.PublishedDate)"
|
|
||||||
|
|
||||||
if (-not($SimulationMode)) {
|
|
||||||
try {
|
|
||||||
Install-Module -Name $module -Force -SkipPublisherCheck -ErrorAction Stop
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
Write-Warning "$module - $($_.Exception.Message)"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
elseif ($moduleGalleryInfo.Version -eq $currentVersion) {
|
|
||||||
Write-Host -ForegroundColor Green "$module already in latest version: $currentVersion - Release date: $($moduleGalleryInfo.PublishedDate)"
|
|
||||||
}
|
|
||||||
elseif ($currentVersion.count -gt 1) {
|
|
||||||
Write-Host -ForegroundColor Yellow "$module is installed in $($currentVersion.count) versions (versions: $($currentVersion -join ' | '))"
|
|
||||||
Write-Host -ForegroundColor Cyan "$module - Uninstall previous $module version(s) below the latest version ($($moduleGalleryInfo.Version))"
|
|
||||||
|
|
||||||
Remove-OldPowerShellModules -ModuleName $module -GalleryVersion $moduleGalleryInfo.Version
|
|
||||||
|
|
||||||
# Check again the current Version as we uninstalled some old versions
|
|
||||||
$currentVersion = (Get-InstalledModule -Name $module).Version
|
|
||||||
|
|
||||||
if ($moduleGalleryInfo.Version -ne $currentVersion) {
|
|
||||||
Write-Host -ForegroundColor Cyan "$module - Install from PowerShellGallery version $($moduleGalleryInfo.Version) - Release date: $($moduleGalleryInfo.PublishedDate)"
|
|
||||||
if (-not($SimulationMode)) {
|
|
||||||
try {
|
|
||||||
Install-Module -Name $module -Force -ErrorAction Stop
|
|
||||||
|
|
||||||
Remove-OldPowerShellModules -ModuleName $module -GalleryVersion $moduleGalleryInfo.Version
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
Write-Warning "$module - $($_.Exception.Message)"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
# https://invoke-thebrain.com/2018/12/comparing-version-numbers-powershell/
|
|
||||||
elseif ([version]$currentVersion -gt [version]$moduleGalleryInfo.Version) {
|
|
||||||
Write-Host -ForegroundColor Yellow "$module - the current version $currentVersion is newer than the version available on PowerShell Gallery $($moduleGalleryInfo.Version) (Release date: $($moduleGalleryInfo.PublishedDate)). Sometimes happens when you install a module from another repository or via .exe/.msi or if you change the version number manually."
|
|
||||||
}
|
|
||||||
elseif ([version]$currentVersion -lt [version]$moduleGalleryInfo.Version) {
|
|
||||||
Write-Host -ForegroundColor Cyan "$module - Update from PowerShellGallery version " -NoNewline
|
|
||||||
Write-Host -ForegroundColor White "$currentVersion -> $($moduleGalleryInfo.Version) " -NoNewline
|
|
||||||
Write-Host -ForegroundColor Cyan "- Release date: $($moduleGalleryInfo.PublishedDate)"
|
|
||||||
|
|
||||||
if (-not($SimulationMode)) {
|
|
||||||
try {
|
|
||||||
Update-Module -Name $module -Force -ErrorAction Stop
|
|
||||||
Remove-OldPowerShellModules -ModuleName $module -GalleryVersion $moduleGalleryInfo.Version
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
if ($_.Exception.Message -match 'Authenticode') {
|
|
||||||
Write-Host -ForegroundColor Yellow "$module - The module certificate used by the creator is either changed since the last module install or the module sign status has changed."
|
|
||||||
|
|
||||||
if ($SkipPublisherCheck.IsPresent) {
|
|
||||||
Write-Host -ForegroundColor Cyan "$module - SkipPublisherCheck Parameter is present, so install will run without Authenticode check"
|
|
||||||
Write-Host -ForegroundColor Cyan "$module - Install from PowerShellGallery version $($moduleGalleryInfo.Version) - Release date: $($moduleGalleryInfo.PublishedDate)"
|
|
||||||
try {
|
|
||||||
Install-Module -Name $module -Force -SkipPublisherCheck
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
Write-Warning "$module - $($_.Exception.Message)"
|
|
||||||
}
|
|
||||||
|
|
||||||
Remove-OldPowerShellModules -ModuleName $module -GalleryVersion $moduleGalleryInfo.Version
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Write-Warning "$module - If you want to update this module, run again with -SkipPublisherCheck switch, but please keep in mind the security risk"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Write-Warning "$module - $($_.Exception.Message)"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pause
|
pause
|
||||||
|
|||||||
Reference in New Issue
Block a user