Skip to content

[#105020746] Added uninstall to MSI #1069

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 6, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions setup-powershellget/Setup/ShortcutStartup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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\"
Expand All @@ -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'.
Expand Down
2 changes: 2 additions & 0 deletions setup-powershellget/azurecmd.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,14 @@
<CustomAction Id="UpdatePSShortcut" BinaryKey="CustomActions" DllEntry="UpdatePSShortcut" Execute ="deferred" Impersonate="no"/>
<CustomAction Id="SetExecutionPolicy" Property="POWERSHELLEXE" ExeCommand="-NoLogo -NoProfile -Command &quot;Set-ExecutionPolicy RemoteSigned -Force&quot;" Execute="deferred" Impersonate="no" Return="check"/>
<CustomAction Id="RunModuleInstallScript" Property="POWERSHELLEXE" ExeCommand="-NoLogo -NoProfile -Command &quot;. \&quot;[PowerShellFolder]\ShortcutStartup.ps1\&quot; -Install&quot;" Execute="deferred" Impersonate="no" Return="check"/>
<CustomAction Id="RunModuleUninstallScript" Property="POWERSHELLEXE" ExeCommand="-NoLogo -NoProfile -Command &quot;. \&quot;[PowerShellFolder]\ShortcutStartup.ps1\&quot; -Uninstall&quot;" Execute="deferred" Impersonate="no" Return="check"/>

<InstallExecuteSequence>
<Custom Action="SetCustomActionDataValue" After="CreateShortcuts">NOT Installed</Custom>
<Custom Action="UpdatePSShortcut" After="SetCustomActionDataValue">NOT Installed</Custom>
<Custom Action="SetExecutionPolicy" After="UpdatePSShortcut">NOT Installed</Custom>
<Custom Action="RunModuleInstallScript" After="SetExecutionPolicy">NOT Installed</Custom>
<Custom Action="RunModuleUninstallScript" After="InstallInitialize">(NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")</Custom>
</InstallExecuteSequence>

<WixVariable Id="WixUILicenseRtf" Value="$(var.ProjectDir)\media\License.rtf" />
Expand Down
2 changes: 1 addition & 1 deletion tools/AzureRM/AzureRM.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
Expand Down