Scripts/uninstall-7zip.ps1

<#
.SYNOPSIS
  Wrapper script for uninstalling 7-zip
 
.DESCRIPTION
  Provides functionality for downloading and installing packages, including logging and exit codes.
 
.PARAMETER User
  Mandatory : Generic or customer specific login on dist server. Use quotation marks!
.PARAMETER Pass
  Mandatory : Password for dist server (mandatory). Use quotation marks!
 
.EXAMPLE
  > Powershell.exe -ExecutionPolicy ByPass -File .\install-SomeApplication.ps1 -User "CUST-Kakbolaget" -Pass "sup3rs3cr3tp@ssw0rd"
 
.NOTES
  Version: 1.0
  Author: Mikael Karlsson
 
  Version history
  1.0 2023-10-09 - Initial release
 
.LINK
  Documentation: https://nordlosthc.eu.itglue.com/1649140723777754/documents/folder/3389170169659635/
  Wrapper scripts: https://nordlo.sharepoint.com/:f:/r/sites/city/Leverans/Internt/St%C3%B6dsystem/Dist/Install%20Wrappers?csf=1&web=1&e=OmV9eo
#>


[CmdletBinding()]
Param(
  [Parameter(Mandatory=$false)] [String]$User,
  [Parameter(Mandatory=$false)] [string]$Pass
)

$FunctionsLibrary = "DeployLibNorEvo"
$Global:User = $User
$Global:Pass = $Pass
$Global:ScriptName = Split-Path -Leaf $MyInvocation.MyCommand.Path
$null = Install-PackageProvider -Name "NuGet" -Force
Remove-Module $FunctionsLibrary -Force -ErrorAction SilentlyContinue
Install-Module -Name $FunctionsLibrary -Scope CurrentUser -Force
Start-NEDeploySession

### Custom Code Starts ####################################################################################################################

### Uninstall 7-Zip
$AppDeploy_Name = "7-zip"

Write-Log "Getting Indentifying Number for $AppDeploy_Name "
$W = (Get-WmiObject -Class Win32_Product | Where-Object { $_.Name -like "*$AppDeploy_Name *" }).IdentifyingNumber
# Uninstall if Intifying Number was found
if ($W) {
  Write-NELog "Initiating uninstalltion of $AppDeploy_Name $W"
    $i = Start-Process -FilePath "msiexec.exe" -Wait -PassThru -ArgumentList "/X$W /qn /norestart /L `"$AppInstallLogDir\$AppDeploy_Name uninstall.log`""
    Invoke-NEInstallResult -ExitCode $i.Exitcode
}

else { Write-NELog "Application $AppDeploy_Name was not fond on system" }

### Custom Code Ends ####################################################################################################################
Invoke-NEFinalAction