|
function RebootIfRequired(){ |
|
if (Test-PendingReboot) { |
|
Invoke-Reboot |
|
} |
|
} |
|
|
|
$keys = Get-Package -Provider Programs -IncludeWindowsInstaller -Name "Beckhoff TF5400 *" -ErrorAction SilentlyContinue |
|
foreach($key in $keys) |
|
{ |
|
$package = $key.Name |
|
Uninstall-Package -Name "$package" |
|
} |
|
|
|
RebootIfRequired |
|
|
|
$keys = Get-Package -Provider Programs -IncludeWindowsInstaller -Name "Beckhoff TwinCAT 3.1 Remote Manager *" -ErrorAction SilentlyContinue |
|
foreach($key in $keys) |
|
{ |
|
$package = $key.Name |
|
Uninstall-Package -Name "$package" |
|
RebootIfRequired |
|
if(Test-PendingReboot){ |
|
break |
|
} |
|
} |
|
|
|
# Removing TwinCAT 3 Measurement requires a different approach, it doesn't respond to `Uninstall-Package`. Instead, |
|
# get the uninstall string from the registry and call that command. |
|
$app = Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object DisplayName -eq "Beckhoff TwinCAT 3 Measurement" |
|
if ($null -ne $app) |
|
{ |
|
$command = $app.UninstallString |
|
$split = $command.Split('"') |
|
Start-Process $split[1] -ArgumentList $split[2] -Wait |
|
} |
|
|
|
RebootIfRequired |
|
|
|
# Separate package list in 2 in order to force a reboot in between. |
|
$keys = @('Beckhoff Support Info Report', |
|
'Beckhoff Target Browser', |
|
'Beckhoff TE130x Scope View', |
|
'Beckhoff TE132x Bode Plot', |
|
'Beckhoff TE9000 TwinSAFE Editor', |
|
'Beckhoff TF3110 TC3 Filter Designer', |
|
'Beckhoff TF3300 Scope Server', |
|
'Beckhoff TwinCAT 3 Application Runtime Libraries (x64)', |
|
'Beckhoff TwinCAT 3 BlockDiagram') |
|
|
|
$keys2 = @('Beckhoff TwinCAT 3 Measurement Base', |
|
'Beckhoff TwinCAT 3 Type System (x64)', |
|
'Beckhoff TwinCAT 3 x64 Driver Package', |
|
'Beckhoff TwinCAT MultiUser', |
|
'Beckhoff TwinCAT MultiUser Git', |
|
'Beckhoff TwinCAT PnP Driver Package', |
|
'Beckhoff TwinCAT XAE Shell', |
|
'Beckhoff TwinCAT Embedded Browser', |
|
'Beckhoff TwinCAT 3.1 (Build 4024)', |
|
'Beckhoff TwinCAT 3 Measurement', |
|
'Beckhoff TwinCAT AML DataExchange') |
|
|
|
foreach($key in $keys) |
|
{ |
|
if ($null -ne (Get-Package -Provider Programs -IncludeWindowsInstaller -Name "$key" -ErrorAction SilentlyContinue)){ |
|
Uninstall-Package -Name "$key" |
|
RebootIfRequired |
|
if(Test-PendingReboot){ |
|
break |
|
} |
|
} |
|
} |
|
|
|
RebootIfRequired |
|
|
|
foreach($key in $keys2) |
|
{ |
|
if ($null -ne (Get-Package -Provider Programs -IncludeWindowsInstaller -Name "$key" -ErrorAction SilentlyContinue)){ |
|
Uninstall-Package -Name "$key" |
|
RebootIfRequired |
|
if(Test-PendingReboot){ |
|
break |
|
} |
|
} |
|
} |
|
|
|
# Remove any remaining items starting with "Beckhoff " from Programs and Features |
|
$keys = Get-Package -Provider Programs -IncludeWindowsInstaller -Name "Beckhoff *" -ErrorAction SilentlyContinue |
|
foreach($key in $keys) |
|
{ |
|
$package = $key.Name |
|
Uninstall-Package -Name "$package" |
|
RebootIfRequired |
|
if(Test-PendingReboot){ |
|
break |
|
} |
|
} |
|
|
|
RebootIfRequired |
|
|
|
Remove-Item -Path "$env:programdata\Beckhoff" -Force -Recurse |
|
Remove-Item -Path "${env:programfiles(x86)}\Beckhoff" -Force -Recurse |
|
Remove-Item -Path "HKLM:\SOFTWARE\WOW6432Node\Beckhoff\TwinCAT3" -Force -Recurse |
|
Remove-Item -Path "C:\TwinCAT\3.1" -Force -Recurse |