-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUndo-Local.ps1
More file actions
50 lines (41 loc) · 1.43 KB
/
Undo-Local.ps1
File metadata and controls
50 lines (41 loc) · 1.43 KB
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
# Description: This script will remove the AzKube module from the local repository and unregister the NuGet repository.
#
# .\Undo-Local.ps1
#
$nugetRepoPath = "$PSScriptRoot\src\AzKube\NuGetRepo"
# Remove the module from the local repository
if (Get-Module -Name AzKube) {
Remove-Module -Name AzKube -Force
# Verify the module is removed
if (!(Get-Module -Name AzKube -ErrorAction SilentlyContinue)) {
Write-Host "The AzKube module has been removed"
}
else {
Write-Host "The AzKube module has not been removed"
}
}
# Uninstall the module
if (Get-Module -Name AzKube -ListAvailable) {
Uninstall-Module -Name AzKube -Force -AllVersions
}
# Unregister the NuGet repository
Unregister-PSRepository -Name AzKubeRepo -ErrorAction SilentlyContinue
Push-Location $PSScriptRoot
# Remove the NuGet repository
if (Test-Path $nugetRepoPath) {
Remove-Item -Path $nugetRepoPath -Force -Recurse
}
# Remove the module from the PSModulePath
$path = (Resolve-Path './src/AzKube').Path
Write-Debug $path
if ($env:PSModulePath -like "*$path*") {
$escapedAzKubePath = $path -replace "\\", "\\\\\\\\"
Write-Debug $escapedAzKubePath
$escapedPSModulePath = $env:PSModulePath -replace "\\", "\\\\"
$removedPath = $escapedPSModulePath -replace ";$escapedAzKubePath", ""
Write-Debug $removedPath
if ($removedPath -ne '') {
$env:PSModulePath = $removedPath -replace "\\\\\\\\", "\"
}
}
Pop-Location