-
Notifications
You must be signed in to change notification settings - Fork 1
/
Uninstall-Scripts.ps1
73 lines (59 loc) · 2.18 KB
/
Uninstall-Scripts.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<#
.SYNOPSIS
Uninstalls prerequisites for scripts.
.DESCRIPTION
Uninstalls prerequisites for scripts.
.INPUTS
None.
.OUTPUTS
None.
.EXAMPLE
PS> .\Uninstall-Scripts
#>
# ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#Requires -Version 5.0
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'Medium')]
param ([Parameter()] [switch] $UpdateHelp,
[Parameter(Mandatory = $true)] [string] $ModulesPath)
Begin
{
$script = $MyInvocation.MyCommand.Name
if(-Not (Test-Path ".\$script"))
{
Write-Host "Uninstallation must be run from the same directory as the uninstaller script."
exit
}
if(-Not (Test-Path $ModulesPath))
{
Write-Host "'$ModulesPath' was not found."
exit
}
$Env:PSModulePath += ";$ModulesPath"
if (-Not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Start-Process -FilePath "pwsh.exe" -ArgumentList "-File `"$PSCommandPath`"", "-ModulesPath `"$ModulesPath`"" -Verb RunAs
exit
}
}
Process
{
Import-LocalModule "Varan.PowerShell.Base"
Import-LocalModule "Varan.PowerShell.Common"
Import-LocalModule "Varan.PowerShell.SelfElevate"
Remove-PathFromProfile -PathVariable 'Path' -Path (Get-Location).Path
Remove-PathFromProfile -PathVariable 'PSModulePath' -Path $ModulesPath
Remove-ImportModuleFromProfile "Varan.PowerShell.Base"
Remove-ImportModuleFromProfile "Varan.PowerShell.Common"
Remove-ImportModuleFromProfile "Varan.PowerShell.SelfElevate"
Remove-AliasFromProfile -Script 'Get-SystemHelp' -Alias 'syshelp'
Remove-AliasFromProfile -Script 'Get-SystemHelp' -Alias 'gsh'
Remove-AliasFromProfile -Script 'Install-CustomConfiguration' -Alias 'sysic'
Remove-AliasFromProfile -Script 'Install-CustomConfiguration' -Alias 'icc'
Remove-AliasFromProfile -Script 'Get-CustomConfigurationScriptVersion' -Alias 'ccver'
Remove-AliasFromProfile -Script 'Get-CustomConfigurationScriptVersion' -Alias 'gccsv'
Remove-PathFromProfile -Text '$ConfirmPreference = ''None'''
}
End
{
Format-Profile
Complete-Install
}