Created
January 24, 2022 23:15
-
-
Save wise-io/a3c64423382d5b43422f2374bd7756eb to your computer and use it in GitHub Desktop.
Office Deployment & LibreOffice / WPS Office Removal Scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
Installs Microsoft Office with ODT (Office Deployement Tool) | |
.DESCRIPTION | |
This script downloads ODT to download/install Microsoft Office with the provided configuration file. You will need to download the Microsoft ODT tool and run it to get the ODT setup executable. | |
.EXAMPLE | |
./InstallOffice.ps1 -config "https://example.com/linktoconfig.xml" -download | |
.LINK | |
ODT Download: https://www.microsoft.com/en-us/download/details.aspx?id=49117 | |
XML Configuration Generator: https://config.office.com/ | |
#> | |
Param( | |
[Parameter (Mandatory=$true)] | |
[string]$Config, # Link to configuration xml file | |
[switch]$Download # Downloads Office if set | |
) | |
$DeploymentToolDownloadURL = "" # Add download URL to ODT Setup executable here. | |
$DeploymentTool = "$env:temp\office-deployment-tool.exe" | |
$ConfigFile = "$env:temp\office-config.xml" | |
# Download Office Deployment Tool | |
Invoke-WebRequest -Uri $DeploymentToolDownloadURL -OutFile $DeploymentTool | |
# Download Configuration File | |
Invoke-WebRequest -Uri $Config -OutFile $ConfigFile | |
# Download Office If Requested | |
if($Download) { | |
Start-Process -Wait -Filepath $DeploymentTool -ArgumentList "/download $ConfigFile" | |
} | |
# Install Office | |
Start-Process -Wait -Filepath $DeploymentTool -ArgumentList "/configure $ConfigFile" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Removes LibreOffice Installations (x32 & x64) | |
$Paths = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall', 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall' | |
$App = Get-ChildItem -Path $Paths | Get-ItemProperty | Where-Object {$_.DisplayName -like "LibreOffice*" } | Select-Object | |
ForEach ($Ver in $App) { | |
If ($Ver.UninstallString) { | |
$DisplayName = $Ver.DisplayName | |
$Uninst = $Ver.PSChildName | |
Write-Output "Uninstalling $DisplayName..." | |
cmd /c msiexec.exe /qn /uninstall $Uninst | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Removes WPS (Kingsoft) Office User Based Installs | |
$App = Get-ChildItem -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall | Get-ItemProperty | Where-Object {$_.Publisher -like "Kingsoft*" } | Select-Object -Property DisplayName, UninstallString | |
ForEach ($Ver in $App) { | |
If ($Ver.UninstallString) { | |
$DisplayName = $Ver.DisplayName | |
$Uninst = $Ver.UninstallString | |
Write-Output "Uninstalling $DisplayName..." | |
cmd /c $Uninst /s | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment