<#
Script to clean all of the Stadlerrail Imsim Apps and data stored and used by it
#>
# Get all of the application installed with Vendor parameter equals 'Stadlerrail'
Write-Information "Collecting data for installed application ..."
$stadlerrailApps = Get-WmiObject -Class Win32_Product -Filter "Vendor = 'Stadlerrail'"
if ($stadlerrailApps.Length -eq 0) {
Write-Warning "There are no application installed. If you disagree - you should remove it manually"
}
# Uninstall in loop
foreach ($app in $stadlerrailApps) {
Write-Information "Removing $($app.Name) ..."
$app.Uninstall()
}
# Get default storage path
$appLocalStorage = Join-Path -Path $env:USERPROFILE -ChildPath ".imsim"
Write-Information "Default local storage path is [$appLocalStorage]. Checking if it exists ..."
# Check if folder exists and remove it
if (Test-Path $appLocalStorage) {
$message = "Found [$appLocalStorage]."
$question = 'Are you sure you want to remove it?'
$choices = '&Yes', '&No'
$decision = $Host.UI.PromptForChoice($message, $question, $choices, 1)
if ($decision -eq 0) {
Write-Information "Removing local storage ..."
Remove-Item -Path $appLocalStorage -Recurse -Force
} else {
Write-Information "Oki-Doki"
}
} else {
Write-Warning "No local storage found. Guess its OK"
}
Pause