diff --git a/setup-powershellget/Setup/ShortcutStartup.ps1 b/setup-powershellget/Setup/ShortcutStartup.ps1 index de49c4edd1b9..2247c2e2dde0 100644 --- a/setup-powershellget/Setup/ShortcutStartup.ps1 +++ b/setup-powershellget/Setup/ShortcutStartup.ps1 @@ -11,10 +11,12 @@ # See the License for the specific language governing permissions and # limitations under the License. # ---------------------------------------------------------------------------------- -[CmdletBinding()] +[CmdletBinding(DefaultParametersetName="none")] Param( -[Parameter(Mandatory=$False, HelpMessage="Use Install parameter to install Azure modules from PowerShell Gallery.")] -[switch]$Install +[Parameter(Mandatory=$True, HelpMessage="Use Install parameter to install Azure modules from PowerShell Gallery.", ParameterSetName="install")] +[switch]$Install, +[Parameter(Mandatory=$True, HelpMessage="Use Uninstall parameter to uninstall Azure modules from PowerShell Gallery.", ParameterSetName="uninstall")] +[switch]$Uninstall ) function EnsureRegistryPath @@ -38,7 +40,7 @@ try { Write-Output @" Finalizing installation of Azure PowerShell. -Installing Azure Modules from PowerShell Gallery. +Installing AzureRM Modules from PowerShell Gallery. This may take some time... "@ $env:PSModulePath = "$env:USERPROFILE\Documents\WindowsPowerShell\Modules;$env:ProgramFiles\WindowsPowerShell\Modules;$env:SystemRoot\system32\WindowsPowerShell\v1.0\Modules\" @@ -59,7 +61,20 @@ This may take some time... Write-Output "AzureRM $((Get-InstalledModule -Name AzureRM)[0].Version) installed..." Update-AzureRM -Repository $DefaultPSRepository - } else { + } + elseif ($Uninstall.IsPresent) + { + Write-Output @" + +Finalizing uninstallation of Azure PowerShell. +This may take some time... +"@ + $env:PSModulePath = "$env:USERPROFILE\Documents\WindowsPowerShell\Modules;$env:ProgramFiles\WindowsPowerShell\Modules;$env:SystemRoot\system32\WindowsPowerShell\v1.0\Modules\" + + Uninstall-AzureRM + } + else + { cd c:\ $welcomeMessage = @" For a list of all Azure RM cmdlets type 'help azurerm'. diff --git a/setup-powershellget/azurecmd.wxs b/setup-powershellget/azurecmd.wxs index bca2e41bc536..25d5e5df82bc 100644 --- a/setup-powershellget/azurecmd.wxs +++ b/setup-powershellget/azurecmd.wxs @@ -97,12 +97,14 @@ + NOT Installed NOT Installed NOT Installed NOT Installed + (NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL") diff --git a/tools/AzureRM/AzureRM.psm1 b/tools/AzureRM/AzureRM.psm1 index b18d5f2e1b49..1f13d4366202 100644 --- a/tools/AzureRM/AzureRM.psm1 +++ b/tools/AzureRM/AzureRM.psm1 @@ -33,7 +33,7 @@ function Test-AdminRights([string]$Scope) $isAdmin = (New-Object Security.Principal.WindowsPrincipal $user).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator) if($isAdmin -eq $false) { - throw "Administrator rights are required to install Microsoft Azure modules" + throw "Administrator rights are required to install or uninstall Microsoft Azure modules" } } }