diff --git a/tools/AzureRM.BootStrapper/AzureRM.BootStrapper.psd1 b/tools/AzureRM.BootStrapper/AzureRM.BootStrapper.psd1 index 69750edec34a..97454ff9ce6e 100644 --- a/tools/AzureRM.BootStrapper/AzureRM.BootStrapper.psd1 +++ b/tools/AzureRM.BootStrapper/AzureRM.BootStrapper.psd1 @@ -69,7 +69,7 @@ PowerShellVersion = '5.0' # NestedModules = @() # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. -FunctionsToExport = 'Get-AzureRmProfile', 'Use-AzureRmProfile', 'Install-AzureRmProfile', 'Uninstall-AzureRmProfile', 'Get-AzureRmModule', 'Set-BootstrapRepo' +FunctionsToExport = 'Get-AzureRmProfile', 'Use-AzureRmProfile', 'Install-AzureRmProfile', 'Uninstall-AzureRmProfile', 'Get-AzureRmModule', 'Update-AzureRmProfile', 'Set-BootstrapRepo' # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. CmdletsToExport = @() diff --git a/tools/AzureRM.BootStrapper/AzureRM.Bootstrapper.ScenarioTests.ps1 b/tools/AzureRM.BootStrapper/AzureRM.Bootstrapper.ScenarioTests.ps1 new file mode 100644 index 000000000000..1667c07c96f3 --- /dev/null +++ b/tools/AzureRM.BootStrapper/AzureRM.Bootstrapper.ScenarioTests.ps1 @@ -0,0 +1,531 @@ +Import-Module -Name AzureRM.Bootstrapper +$RollupModule = 'AzureRM' + +function Remove-InstalledProfile { + $installedProfiles = Get-AzureRmProfile + if ($installedProfiles -ne $null) + { + foreach ($profile in $installedProfiles) + { + Write-Host "Removing profile $profile" + Uninstall-AzureRmProfile -Profile $profile -Force -ErrorAction Stop + } + + $profiles = (Get-AzureRmProfile) + if ($profiles -ne $null) + { + Throw "Uninstallation was not successful: Profile(s) $profiles were not uninstalled correctly." + } + } +} + +Describe "A machine with no profile installed can install profile" { + # Using Install-AzureRmProfile + Context "New Profile Install - Latest" { + # Launch the test in a new powershell session + # Arrange + # Uninstall previously installed profiles + Remove-InstalledProfile + + # Create a new PS session + $session = New-PSSession + + # Act + # Install latest version + Invoke-Command -Session $session -ScriptBlock { Install-AzureRmProfile -Profile 'Latest' } + + # Assert + It "Should return Latest Profile" { + Invoke-Command -Session $session -ScriptBlock { Get-AzureRmProfile } | Should Be 'Latest' + } + + # Clean up + Invoke-Command -Session $session -ScriptBlock { Uninstall-AzureRmProfile -Profile 'Latest' -Force } + Remove-PSSession -Session $session + } + + # Using Use-AzureRmProfile + Context "New Profile Install - 2016-09" { + # Arrange + # Uninstall previously installed profiles + Remove-InstalledProfile + + # Create a new PS session + $session = New-PSSession + + # Act + # Install profile '2016-09' + Invoke-Command -Session $session -ScriptBlock { Use-AzureRmProfile -Profile '2016-09' -Force } + + # Assert + It "Should return 2016-09" { + Invoke-Command -Session $session -ScriptBlock { Get-AzureRmProfile } | Should Be '2016-09' + } + + # Clean up + # Invoke-Command -Session $session -ScriptBlock { Uninstall-AzureRmProfile -Profile '2016-09' -Force -ea SilentlyContinue } + Remove-PSSession -Session $session + } + +} + +Describe "Add: A Machine with a Profile installed can install latest profile" { + Context "Profile 2016-09 already installed" { + # Arrange + # Create a new PS session + $session = New-PSSession + + # Ensure 2016-09 is installed + $profilesInstalled = Invoke-Command -Session $session -ScriptBlock { Get-AzureRmProfile } + $profilesInstalled | Should Be '2016-09' + + # Act + # Install profile 'Latest' + Invoke-Command -Session $session -ScriptBlock { Use-AzureRmProfile -Profile 'Latest' -Force } + $result = Invoke-Command -Session $session -ScriptBlock { Get-AzureRmProfile } + + # Assert + It "Should return 2016-09 & Latest" { + $result.Length | Should Be 2 + $result.Contains('2016-09') | Should Be $true + $result.Contains('Latest') | Should Be $true + } + + # Clean up + Remove-PSSession -Session $session + } +} + +Describe "Attempting to use already installed profile will import the modules to the current session" { + Context "Profile Latest is installed" { + # Should import Latest profile to current session + # Arrange + # Create a new PS session + $session = New-PSSession + + # Ensure profile Latest is installed + $profilesInstalled = Invoke-Command -Session $session -ScriptBlock { Get-AzureRmProfile } + $profilesInstalled.Contains('Latest') | Should Be $true + + # Act + Invoke-Command -Session $session -ScriptBlock { Use-AzureRmProfile -Profile 'Latest' } + + # Get the version of the Latest profile + $ProfileMap = Get-AzProfile + $latestVersion = $ProfileMap.'Latest'.$RollupModule + + # Assert + It "Should return AzureRm module Latest version" { + # Get-module script block + $getModule = { + Param($RollupModule) + Get-Module -Name $RollupModule + } + + $modules = Invoke-Command -Session $session -ScriptBlock $getModule -ArgumentList $RollupModule + + $modules.Name | Should Be $RollupModule + $modules.version | Should Be $latestVersion + } + + # Cleanup + Invoke-Command -Session $session -ScriptBlock { Uninstall-AzureRmProfile -Profile 'Latest' -Force -ea SilentlyContinue } + Remove-PSSession -Session $session + } +} + +Describe "User can update their machine to a latest profile" { + + # Using Use-AzureRmProfile + Context "Profile 2016-09 is installed" { + # Should refresh profile map from Azure end point and update modules. + # Arrange + # Create a new PS session + $session = New-PSSession + + # Check if '2016-09' is installed + $profilesInstalled = Invoke-Command -Session $session -ScriptBlock { Get-AzureRmProfile } + $profilesInstalled | Should Be '2016-09' + + # Act + Invoke-Command -Session $session -ScriptBlock { Get-AzureRmProfile -Update } + Invoke-Command -Session $session -ScriptBlock { Use-AzureRmProfile -Profile 'Latest' -Force } + + # Assert + It "Should return 2016-09 & Latest" { + $result = Invoke-Command -Session $session -ScriptBlock { Get-AzureRmProfile } + $result.Length | Should Be 2 + $result.Contains('2016-09') | Should Be $true + $result.Contains('Latest') | Should Be $true + } + + It "Latest version of modules are imported" { + # Get the version of the Latest profile + $ProfileMap = Get-AzProfile + $latestVersion = $ProfileMap.'Latest'.$RollupModule + + # Get-module script block + $getModule = { + Param($RollupModule) + Get-Module -Name $RollupModule + } + + $modules = Invoke-Command -Session $session -ScriptBlock $getModule -ArgumentList $RollupModule + + # Are latest modules imported? + $modules.Name | Should Be $RollupModule + $modules.version | Should Be $latestVersion + } + + It "Last Write Time should be less than 5 minutes" { + # Get LastWriteTime for ProfileMap + $lastWriteTime = (Get-Item -Path (Join-Path $Env:LocalAppData -ChildPath 'Microsoft\AzurePowerShell\ProfileCache\ProfileMap.json')).LastWriteTime + (((Get-Date) - $lastWriteTime).TotalMinutes -lt 5) | Should Be $true + } + + # Cleanup + Remove-PSSession -Session $session + } + + # Using Update-AzureRmProfile + Context "Profile 2016-08 is installed" { + # Arrange + # Remove existing profiles + Remove-InstalledProfile + + # Create a new PS session + $session = New-PSSession + + # Install profile 2016-08 + Install-AzureRmProfile -Profile '2016-08' + + # Ensure profile 2016-08 is installed + Get-AzureRmProfile | Should Be '2016-08' + + # Act + # Update to profile 'Latest' + Invoke-Command -Session $session -ScriptBlock { Update-AzureRmProfile -Profile 'Latest' -Force -RemovePreviousVersions } + + # Assert + # Returns only Latest, because 2016-08 was removed with -RemovePreviousVersions flag + It "Should return only 'Latest'" { + Get-AzureRmProfile | Should Be 'Latest' + } + + It "Latest version of modules are imported" { + # Get the version of the Latest profile + $ProfileMap = Get-AzProfile + $latestVersion = $ProfileMap.'Latest'.$RollupModule + + # Get-module script block + $getModule = { + Param($RollupModule) + Get-Module -Name $RollupModule + } + + $modules = Invoke-Command -Session $session -ScriptBlock $getModule -ArgumentList $RollupModule + + # Are latest modules imported? + $modules.Name | Should Be $RollupModule + $modules.version | Should Be $latestVersion + } + + Remove-PSSession -Session $session + } +} + +Describe "User can uninstall a profile" { + Context "Latest profile is installed" { + # Should uninstall latest profile + # Arrange + # Create a new PS session + $session = New-PSSession + + # Check if 'Latest' is installed + $profilesInstalled = Invoke-Command -Session $session -ScriptBlock { Get-AzureRmProfile } + $profilesInstalled.Contains('Latest') | Should Be $true + + # Get the version of the Latest profile + $ProfileMap = Get-AzProfile + $latestVersion = $ProfileMap.'Latest'.$RollupModule + + # Act + Invoke-Command -Session $session -ScriptBlock { Uninstall-AzureRmProfile -Profile 'Latest' -Force } + + # Assert + It "Profile Latest is uninstalled" { + $result = Invoke-Command -Session $session -ScriptBlock { Get-AzureRmProfile } + if($result -ne $null) + { + $result.Contains('Latest') | Should Be $false + } + else { + $true + } + } + + It "Available Modules should not contain uninstalled modules" { + $getModule = { + Param($RollupModule) + Get-Module -Name $RollupModule -ListAvailable + } + $result = Invoke-Command -Session $session -ScriptBlock $getModule -ArgumentList $RollupModule + $result.Version -eq $latestVersion | Should Be $false + } + + # Cleanup + Remove-PSSession -Session $session + } +} + +Describe "Install Two named profiles and selecting each" { + # Get the version of the respective profile + $ProfileMap = Get-AzProfile + $Version1 = $ProfileMap.'2016-08'.$RollupModule + $Version2 = $ProfileMap.'2016-04'.$RollupModule + + Context "Install Two Profiles" { + # Arrange + # Remove all profiles + Remove-InstalledProfile + + # Create a new PS session + $session = New-PSSession + + # Act + # Install Profile: 2016-08 + Invoke-Command -Session $session -ScriptBlock { Install-AzureRmProfile -Profile '2016-08' } + + # Install Profile: 2016-04 + Invoke-Command -Session $session -ScriptBlock { Install-AzureRmProfile -Profile '2016-04' } + + # Assert + It "Should return Profiles 2016-08 & 2016-04" { + Invoke-Command -Session $session -ScriptBlock { Get-AzureRmProfile } | Should Be @('2016-08', '2016-04') + } + + # Clean up + Remove-PSSession -Session $session + } + + Context "Select diff profiles" { + # Arrange + # Create two new PS sessions + $session1 = New-PSSession + $session2 = New-PSSession + + # Act + # Use-AzureRmProfile will import the respective versions of modules in the session + Invoke-Command -Session $session1 -ScriptBlock { Use-AzureRmProfile -Profile '2016-08' } + Invoke-Command -Session $session2 -ScriptBlock { Use-AzureRmProfile -Profile '2016-04' } + + $getModule = { + Param($RollupModule) + Get-Module -Name $RollupModule + } + + $result = Invoke-Command -Session $session1 -ScriptBlock { Get-AzureRmProfile } + $module1 = Invoke-Command -Session $session1 -ScriptBlock $getModule -ArgumentList $RollupModule + $module2 = Invoke-Command -Session $session2 -ScriptBlock $getModule -ArgumentList $RollupModule + + # Assert + It "Should return 2016-08 & 2016-04" { + $result | Should Be @('2016-08', '2016-04') + } + + It "Respective versions of modules are imported" { + # Are respective modules imported? + $module1.Name | Should Be $RollupModule + $module1.version | Should Be $Version1 + + $module2.Name | Should Be $RollupModule + $module2.version | Should Be $Version2 + } + + # "Uninstall All Profiles" + Remove-InstalledProfile + + It "Should return null" { + Get-AzureRmProfile | Should Be $null + } + + It "Modules should return null" { + $getModuleList = { + Param($RollupModule) + Get-Module -ListAvailable -Name $RollupModule + } + + $result1 = Invoke-Command -Session $session1 -ScriptBlock $getModuleList -ArgumentList $RollupModule + $result1.Version -eq $Version1 | Should Be $false + $result2 = Invoke-Command -Session $session2 -ScriptBlock $getModuleList -ArgumentList $RollupModule + $result2.Version -eq $Version2 | Should Be $false + } + + # Cleanup + Remove-PSSession -Session $session1 + Remove-PSSession -Session $session2 + } +} + +Describe "Invalid Cases" { + Context "Install wrong profile name" { + # Arrange + # Create a new PS session + $session = New-PSSession + + # Act & Assert + # Install profile 'abcTest' + It "Throws Invalid argument error" { + Invoke-Command -Session $session -ScriptBlock { Install-AzureRmProfile -Profile 'abcTest' } | Should Throw + } + + # Cleanup + Remove-PSSession -Session $session + } + + Context "Install null profile name" { + # Arrange + # Create a new PS session + $session = New-PSSession + + # Act & Assert + # Install profile 'null' + It "Throws Invalid argument error" { + Invoke-Command -Session $session -ScriptBlock { Install-AzureRmProfile -Profile $null } | Should Throw + } + + # Cleanup + Remove-PSSession -Session $session + } + + Context "Install already installed profile" { + # Arrange + # Create a new PS session + $session = New-PSSession + + # Ensure profile 2016-09 is installed + Install-AzureRmProfile -Profile '2016-09' + $installedProfile = Invoke-Command -Session $session -ScriptBlock { Get-AzureRmProfile } + $installedProfile.contains('2016-09') | Should Be $true + + # Act + # Install profile '2016-09' + $result = Invoke-Command -Session $session -ScriptBlock { Install-AzureRmProfile -Profile '2016-09' } + + # Get modules imported into the session + $getModuleList = { + Param($RollupModule) + Get-Module -Name $RollupModule + } + $modules = Invoke-Command -Session $session -ScriptBlock $getModuleList -ArgumentList $RollupModule + + It "Doesn't install/import the profile" { + $result | Should Be $null + $modules | Should Be $null + } + + # Cleanup + Remove-PSSession -Session $session + } + + Context "Uninstall not installed profile" { + # Arrange + # Create a new PS session + $session = New-PSSession + + # Ensure profile 2015-05 is not installed + $installedProfile = Invoke-Command -Session $session -ScriptBlock { Get-AzureRmProfile } + $installedProfile.contains('2015-05') | Should Be $false + + # Act + # Uninstall profile '2015-05' + $result = Invoke-Command -Session $session -ScriptBlock { Uninstall-AzureRmProfile -Profile '2015-05' -Force} + + It "Doesn't uninstall/throw" { + $result | Should Be $null + } + + # Cleanup + Remove-PSSession -Session $session + } + + Context "Use-AzureRmProfile with wrong profile name" { + # Arrange + # Create a new PS session + $session = New-PSSession + + # Act + # Install profile 'abcTest' + It "Throws Invalid argument error" { + Invoke-Command -Session $session -ScriptBlock { Use-AzureRmProfile -Profile 'abcTest' } | Should Throw + } + + # Cleanup + Remove-PSSession -Session $session + } +} + +Describe "Failure Recovery: Attempt to install profile recovers from error" { + InModuleScope AzureRM.Bootstrapper { + Context "Azure ProfileMap endpoint threw exception" { + # Arrange + # Mock Get-ProfileMap returns error + Mock Get-AzureProfileMap -Verifiable { throw [System.Net.WebException] } + + # Mock Install-Modules returns error + Mock Install-Module -Verifiable { throw } + + # Act & Assert + It "Should not download/install the latest profile" { + { Get-AzureRmProfile -Update } | Should Throw + { Install-AzureRmProfile -Profile 'Latest' } | Should Throw + } + + It "Last Write time should not be less than 3 mins" { + # Get LastWriteTime for ProfileMap + $lastWriteTime = (Get-Item -Path (Join-Path $Env:LocalAppData -ChildPath 'Microsoft\AzurePowerShell\ProfileCache\ProfileMap.json')).LastWriteTime + (((Get-Date) - $lastWriteTime).TotalMinutes -gt 3) | Should Be $true + Assert-VerifiableMocks + } + } + + Context "Retry install after ProfileMap update" { + # Arrange + # Create a new PS session + $session = New-PSSession + + # Act + # Update ProfileMap + Invoke-Command -Session $session -ScriptBlock { Get-AzureRmProfile -Update } + + # Install profile 'Latest' + Invoke-Command -Session $session -ScriptBlock { Use-AzureRmProfile -Profile 'Latest' -Force } + + # Assert + It "Installs & Imports Latest profile to the session" { + $getModuleList = { + Param($RollupModule) + Get-Module -Name $RollupModule + } + $modules = Invoke-Command -Session $session -ScriptBlock $getModuleList -ArgumentList $RollupModule + + # Get the version of the Latest profile + $ProfileMap = Get-AzProfile + $latestVersion = $ProfileMap.'Latest'.$RollupModule + + # Are latest modules imported? + $modules.Name | Should Be $RollupModule + $modules.version | Should Be $latestVersion + } + + It "Last Write time should be less than 5 mins" { + # Get LastWriteTime for ProfileMap + $lastWriteTime = (Get-Item -Path (Join-Path $Env:LocalAppData -ChildPath 'Microsoft\AzurePowerShell\ProfileCache\ProfileMap.json')).LastWriteTime + (((Get-Date) - $lastWriteTime).TotalMinutes -lt 5) | Should Be $true + } + + # Cleanup + Remove-PSSession -Session $session + } + } +} diff --git a/tools/AzureRM.BootStrapper/AzureRM.Bootstrapper.psm1 b/tools/AzureRM.BootStrapper/AzureRM.Bootstrapper.psm1 index da04a7bdcd08..83d90c53d0a6 100644 --- a/tools/AzureRM.BootStrapper/AzureRM.Bootstrapper.psm1 +++ b/tools/AzureRM.BootStrapper/AzureRM.Bootstrapper.psm1 @@ -121,6 +121,19 @@ function Add-ForceParam Add-SwitchParam $params "Force" $set } +function Add-RemoveParam +{ + param([System.Management.Automation.RuntimeDefinedParameterDictionary]$params, [string]$set = "__AllParameterSets") + $name = "RemovePreviousVersions" + $newAttribute = New-Object -Type System.Management.Automation.ParameterAttribute + $newAttribute.ParameterSetName = $set + $newAttribute.Mandatory = $false + $newCollection = New-object -Type System.Collections.ObjectModel.Collection[System.Attribute] + $newCollection.Add($newAttribute) + $newParam = New-Object -Type System.Management.Automation.RuntimeDefinedParameter($name, [switch], $newCollection) + $params.Add($name, [Alias("r")]$newParam) +} + function Add-SwitchParam { param([System.Management.Automation.RuntimeDefinedParameterDictionary]$params, [string]$name, [string] $set = "__AllParameterSets") @@ -245,6 +258,7 @@ function Use-AzureRmProfile $params = New-Object -Type System.Management.Automation.RuntimeDefinedParameterDictionary Add-ProfileParam $params Add-ForceParam $params + Add-RemoveParam $params return $params } PROCESS @@ -354,6 +368,48 @@ function Uninstall-AzureRmProfile } } +<# +.ExternalHelp help\AzureRM.Bootstrapper-help.xml +#> +function Update-AzureRmProfile +{ + [CmdletBinding(SupportsShouldProcess = $true)] + param() + DynamicParam + { + $params = New-Object -Type System.Management.Automation.RuntimeDefinedParameterDictionary + Add-ProfileParam $params + Add-ForceParam $params + Add-RemoveParam $params + return $params + } + + PROCESS { + $ProfileMap = (Get-AzProfile -Update) + $profile = $PSBoundParameters.Profile + + # Remove old profiles? + $Remove = $PSBoundParameters.RemovePreviousVersions + $installedProfiles = Get-AzureRmProfile + foreach ($installedProfile in $installedProfiles) + { + if ($installedProfile -ne $profile) + { + if ($PSCmdlet.ShouldProcess("Profile $installedProfile", "Remove Profile")) + { + if (($Remove.IsPresent -or $PSCmdlet.ShouldContinue("Remove Profile $installedProfile", "Removing profile $installedProfile"))) + { + Uninstall-AzureRmProfile -Profile $installedProfile -Force + } + } + } + } + + # Install & import the required version + Use-AzureRmProfile @PSBoundParameters + } +} + function Set-BootstrapRepo { [CmdletBinding()] diff --git a/tools/AzureRM.BootStrapper/help/AzureRM.Bootstrapper-help.xml b/tools/AzureRM.BootStrapper/help/AzureRM.Bootstrapper-help.xml index 8b396a60c396..4a6465e2ff95 100644 --- a/tools/AzureRM.BootStrapper/help/AzureRM.Bootstrapper-help.xml +++ b/tools/AzureRM.BootStrapper/help/AzureRM.Bootstrapper-help.xml @@ -441,4 +441,143 @@ + +Update-AzureRmProfile +Update +AzureRmProfile +Update a profile to the latest versions in that profile and import updated modules to the current session. This should always be executed in a new PowerShell session. + + + +Update a profile to the latest versions in that profile and import updated modules to the current session. This should always be executed in a new PowerShell session. + + +Update-AzureRmProfile +Profile +The profile version to update and load in the current PowerShell session. + + +2016-09 +2015-05 +<others> + +String +String + + + +Confirm +Request confirmation for any change made by the cmdlet + + +SwitchParameter + +False + +Force +Automatically install modules for the given profile if they are not already installed. + + +SwitchParameter + +False + +RemovePreviousVersions +Automatically remove old versions of the modules currently installed. + + +SwitchParameter + +False + +WhatIf +Print the changes that would be made in executing the cmdlets, but do not make any changes. + + +SwitchParameter + +False + + + +Confirm +Request confrimation for any change made by the cmdlet + + +SwitchParameter +SwitchParameter + +False + +Force +Automatically install modules for the given profile if they are not already installed. + + +SwitchParameter +SwitchParameter + +False + +RemovePreviousVersions +Automatically remove old versions of the modules currently installed. + + +SwitchParameter +SwitchParameter + +False + +Profile +The profile version to load in the current PowerShell session. + + +String +String + + + +WhatIf +Print the changes that would be made in executing the cmdlets, but do not make any changes. + + +SwitchParameter +SwitchParameter + +False + + +None + + + + + + +None + + + + + + + + + + +Example 1 +PS C:\> Update-AzureRmProfile -Profile '2016-09' +Update the modules associated with profile version '2016-09' and load the modules in the current session. This should be executed after opening a new PowerShell session. + + + + +Example 2 +PS C:\> Update-AzureRmProfile -Profile '2016-09' -RemovePreviousVersions -Force +Update the modules associated with profile version '2016-09' and load the modules in the current session. It downloads and installs the required modules and removes old versions of the modules without prompting the user. This should be executed after opening a new PowerShell session. + + + + + + diff --git a/tools/AzureRM.BootStrapper/help/Update-AzureRmProfile.md b/tools/AzureRM.BootStrapper/help/Update-AzureRmProfile.md new file mode 100644 index 000000000000..0ad956f76113 --- /dev/null +++ b/tools/AzureRM.BootStrapper/help/Update-AzureRmProfile.md @@ -0,0 +1,124 @@ +--- +external help file: AzureRM.Bootstrapper-help.xml +online version: +schema: 2.0.0 +--- + +# Update-AzureRmProfile +## SYNOPSIS +Update a profile to the latest versions in that profile and import updated modules to the current session. This should always be executed in a new PowerShell session. + +## SYNTAX + +``` +Update-AzureRmProfile [-WhatIf] [-Confirm] [-Profile] [-Force] [-RemovePreviousVersions] +``` + +## DESCRIPTION +Update a profile to the latest versions in that profile and import updated modules to the current session. This should always be executed in a new PowerShell session. + +## EXAMPLES + +### Example 1 +``` +PS C:\> Update-AzureRmProfile -Profile '2016-09' +``` + +Update the modules associated with profile '2016-09' to their latest versions and load in the current session. This should be executed after opening a new PowerShell session. + +### Example 2 +``` +PS C:\> Update-AzureRmProfile -Profile 'Latest' -RemovePreviousVersions -Force +``` + +Update the modules associated with profile version 'Latest' and load the modules in the current session. It downloads and installs the required modules and removes old versions of the modules without prompting the user. This should be executed after opening a new PowerShell session. + +## PARAMETERS + +### -Confirm +Request confrimation for any change made by the cmdlet + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Force +Automatically install modules for the given profile if they are not already installed. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -RemovePreviousVersions +Automatically remove old versions of the modules currently installed. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: r + +Required: False +Position: Named +Default value: +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Profile +The profile version to load in the current PowerShell session. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: +Accepted values: 2016-09, 2016-05, Latest, + +Required: True +Position: 0 +Default value: +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Print the changes that would be made in executing the cmdlets, but do not make any changes. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: +Accept pipeline input: False +Accept wildcard characters: False +``` + +## INPUTS + +### None + +## OUTPUTS + +### None + +## NOTES + +## RELATED LINKS diff --git a/tools/AzureRM.BootStrapper/help/about_version_profiles.md b/tools/AzureRM.BootStrapper/help/about_version_profiles.md index 71347f347ad2..5fb3ce253057 100644 --- a/tools/AzureRM.BootStrapper/help/about_version_profiles.md +++ b/tools/AzureRM.BootStrapper/help/about_version_profiles.md @@ -91,3 +91,11 @@ This loads the modules associated with the ```2015-05``` profile in the current # Setting the Default Version Profile for all PowerShell sessions # Updating and Removing Profiles + +To update a profile to the latest versions in that profile and import updated modules to the current session, execute the following cmdlet: + +``` +Update-AzureRmProfile -Profile '2016-09' +``` + +This checks if the latest versions of the module in profile ```2016-09``` are installed, if not prompts the user if it should be installed and imports them into the current session. It also prompts the user if the old versions of the module should be removed. This should always be executed in a new PowerShell session.