From 2444a52b0229f0b60466aca167cdfc7999573c7d Mon Sep 17 00:00:00 2001 From: stankovski Date: Wed, 23 Sep 2015 14:36:19 -0700 Subject: [PATCH 1/4] Updated parallel scripts --- setup-powershellget/Setup/ShortcutStartup.ps1 | 19 ++++- tools/AzureRM/AzureRM.psm1 | 85 ++++++++++++------- 2 files changed, 71 insertions(+), 33 deletions(-) diff --git a/setup-powershellget/Setup/ShortcutStartup.ps1 b/setup-powershellget/Setup/ShortcutStartup.ps1 index fed332e89acc..fc17b7356151 100644 --- a/setup-powershellget/Setup/ShortcutStartup.ps1 +++ b/setup-powershellget/Setup/ShortcutStartup.ps1 @@ -26,14 +26,25 @@ Finalizing installation of Azure PowerShell. Installing Azure Modules from PowerShell Gallery. This may take some time... "@ - Import-Module PackageManagement - Get-PackageProvider -Name NuGet -ForceBootstrap + Import-Module "$env:programfiles\WindowsPowerShell\Modules\PackageManagement\1.0.0.0\PackageManagement.psd1" + + $result = Get-PackageProvider -Name NuGet -ForceBootstrap + + Import-Module "$env:programfiles\WindowsPowerShell\Modules\PowerShellGet\PowerShellGet.psd1" $NuGetPublishingSource = $env:NuGetPublishingSource if ([string]::IsNullOrWhiteSpace($NuGetPublishingSource)) { - Install-Module AzureRM -Repository $NuGetPublishingSource - } else { + Install-Module Azure + Write-Output "Azure $((Get-InstalledModule -Name Azure)[0].Version) installed..." Install-Module AzureRM + Write-Output "AzureRM $((Get-InstalledModule -Name AzureRM)[0].Version) installed..." + Update-AzureRM + } else { + Install-Module Azure -Repository $NuGetPublishingSource + Write-Output "Azure $((Get-InstalledModule -Name Azure)[0].Version) installed..." + Install-Module AzureRM -Repository $NuGetPublishingSource + Write-Output "AzureRM $((Get-InstalledModule -Name AzureRM)[0].Version) installed..." + Update-AzureRM -Repository $NuGetPublishingSource } } else { cd c:\ diff --git a/tools/AzureRM/AzureRM.psm1 b/tools/AzureRM/AzureRM.psm1 index dbcfdd49a92b..9b3e46003bad 100644 --- a/tools/AzureRM/AzureRM.psm1 +++ b/tools/AzureRM/AzureRM.psm1 @@ -1,3 +1,30 @@ +$AzureRMModules = ( + "Azure.Storage", + "AzureRM.ApiManagement", + "AzureRM.Automation", + "AzureRM.Backup", + "AzureRM.Batch", + "AzureRM.Compute", + "AzureRM.DataFactories", + "AzureRM.Dns", + "AzureRM.HDInsight", + "AzureRM.Insights", + "AzureRM.KeyVault", + "AzureRM.Network", + "AzureRM.OperationalInsights", + "AzureRM.Profile", + "AzureRM.RedisCache", + "AzureRM.Resources", + "AzureRM.SiteRecovery", + "AzureRM.Sql", + "AzureRM.Storage", + "AzureRM.StreamAnalytics", + "AzureRM.Tags", + "AzureRM.TrafficManager", + "AzureRM.UsageAggregates", + "AzureRM.Websites" +) + <# .Synopsis Install Azure Resource Manager cmdlet modules @@ -13,36 +40,36 @@ #> function Update-AzureRM { - param( - [Parameter(Position=0, Mandatory = $false)] - [string] - $Repository, - - [Parameter(Position=1, Mandatory = $false)] - [ValidateSet("CurrentUser","AllUsers")] - [string] - $Scope) + param( + [Parameter(Position=0, Mandatory = $false)] + [string] + $Repository, - if ([string]::IsNullOrWhiteSpace($Scope)) - { - $Scope = "AllUsers" - } + [Parameter(Position=1, Mandatory = $false)] + [ValidateSet("CurrentUser","AllUsers")] + [string] + $Scope) - Install-Module AzureRM.Profile -Repository $Repository - if ([string]::IsNullOrWhiteSpace($Repository)) - { - $modules = Find-Module -Name AzureRM.* | Where-Object {$_.Name -ne "AzureRM" -and $_.Name -ne "AzureRM.Profile"} - } else { - $modules = Find-Module -Repository $Repository | Where-Object {$_.Name -like "AzureRM.*" -and $_.Name -ne "AzureRM" -and $_.Name -ne "AzureRM.Profile"} - } + if ([string]::IsNullOrWhiteSpace($Scope)) + { + $Scope = "AllUsers" + } - Write-Output "Installing $($modules.Length) AzureRM modules. This may take a few minutes." + Write-Output "Installing AzureRM modules." - $result = $modules | ForEach { - Start-Job -Name $_.Name -ScriptBlock { - Install-Module -Name $args[0] -Repository $args[1] -Scope $args[2] - Write-Output "$($args[0]) installed..." - } -ArgumentList $_.Name, $Repository, $Scope } - - $modules | ForEach {Get-Job -Name $_.Name | Wait-Job | Receive-Job } -} \ No newline at end of file + $result = $AzureRMModules | ForEach { + Start-Job -Name $_ -ScriptBlock { + if ([string]::IsNullOrWhiteSpace($args[1])) + { + Install-Module -Name $args[0] -Scope $args[2] + } else { + Install-Module -Name $args[0] -Repository $args[1] -Scope $args[2] + } + $v = (Get-InstalledModule -Name $args[0])[0].Version.ToString() + Write-Output "$($args[0]) $v installed..." + } -ArgumentList $_, $Repository, $Scope } + + $AzureRMModules | ForEach {Get-Job -Name $_ | Wait-Job | Receive-Job } +} +New-Alias -Name Install-AzureRM -Value Update-AzureRM +Export-ModuleMember -function * -Alias * \ No newline at end of file From b5af0ccd2adb8c4890cf2e5f026d215afbb889e0 Mon Sep 17 00:00:00 2001 From: stankovski Date: Wed, 23 Sep 2015 16:43:54 -0700 Subject: [PATCH 2/4] Work in progress --- build.proj | 2 +- setup-powershellget/Setup/ShortcutStartup.ps1 | 4 +-- tools/PublishModules.ps1 | 31 +++++++++++++------ 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/build.proj b/build.proj index b49b13d339c6..abe9a6ee424d 100644 --- a/build.proj +++ b/build.proj @@ -289,7 +289,7 @@ - + diff --git a/setup-powershellget/Setup/ShortcutStartup.ps1 b/setup-powershellget/Setup/ShortcutStartup.ps1 index fc17b7356151..9ff5d31478bc 100644 --- a/setup-powershellget/Setup/ShortcutStartup.ps1 +++ b/setup-powershellget/Setup/ShortcutStartup.ps1 @@ -26,11 +26,11 @@ Finalizing installation of Azure PowerShell. Installing Azure Modules from PowerShell Gallery. This may take some time... "@ - Import-Module "$env:programfiles\WindowsPowerShell\Modules\PackageManagement\1.0.0.0\PackageManagement.psd1" + Import-Module PackageManagement $result = Get-PackageProvider -Name NuGet -ForceBootstrap - Import-Module "$env:programfiles\WindowsPowerShell\Modules\PowerShellGet\PowerShellGet.psd1" + Import-Module PowerShellGet $NuGetPublishingSource = $env:NuGetPublishingSource if ([string]::IsNullOrWhiteSpace($NuGetPublishingSource)) { diff --git a/tools/PublishModules.ps1 b/tools/PublishModules.ps1 index e8535c77ebc7..ef28708f0d1c 100644 --- a/tools/PublishModules.ps1 +++ b/tools/PublishModules.ps1 @@ -18,7 +18,7 @@ param( [Parameter(Mandatory = $false, Position = 1)] [string] $apiKey, [Parameter(Mandatory = $false, Position = 2)] - [string] $repositoryLocation + [string] $repository ) if ([string]::IsNullOrEmpty($buildConfig)) @@ -29,18 +29,32 @@ if ([string]::IsNullOrEmpty($buildConfig)) if ([string]::IsNullOrEmpty($repositoryLocation)) { - Write-Verbose "Setting repository location to 'http://psget/PSGallery/api/v2/'" - $repositoryLocation = 'http://psget/PSGallery/api/v2/' + Write-Verbose "Setting repository location to 'https://dtlgalleryint.cloudapp.net/api/v2'" + + $repository = 'https://dtlgalleryint.cloudapp.net' } +$repositoryLocation = '$repository/api/v2/' +$repositoryPackageLocation = '$repository/api/v2/package' + + $packageFolder = "$PSScriptRoot\..\src\Package" -$repoName = $(New-Guid).ToString() -Register-PSRepository -Name $repoName -SourceLocation $repositoryLocation -PublishLocation $repositoryLocation -InstallationPolicy Trusted +$repo = Get-PSRepository | where { $_.SourceLocation -eq $repositoryLocation } +if ($repo -ne $null) { + $repoName = $repo.Name +} else { + $repoName = $(New-Guid).ToString() + Register-PSRepository -Name $repoName -SourceLocation $repositoryLocation -PublishLocation $repositoryPackageLocation -InstallationPolicy Trusted +} $modulePath = "$packageFolder\$buildConfig\ServiceManagement\Azure" # Publish Azure module Write-Host "Publishing Azure module from $modulePath" -Publish-Module -Path $modulePath -NuGetApiKey $apiKey -Repository $repoName +Publish-Module -Path $modulePath -NuGetApiKey $apiKey -Repository $repoName -Tags ("Azure", "AzureRM") +# Publish AzureRM module +$modulePath = "$PSScriptRoot\AzureRM" +Write-Host "Publishing AzureRM module from $modulePath" +Publish-Module -Path $modulePath -NuGetApiKey $apiKey -Repository $repoName -Tags ("Azure", "AzureRM") Write-Host "Published Azure module" # Publish AzureRM.Profile module Write-Host "Publishing AzureRM.Profile module from $modulePath" @@ -53,8 +67,7 @@ foreach ($module in $resourceManagerModules) { if ($module -ne "AzureRM.Profile") { $modulePath = $module.FullName Write-Host "Publishing $module module from $modulePath" - Publish-Module -Path $modulePath -NuGetApiKey $apiKey -Repository $repoName + Publish-Module -Path $modulePath -NuGetApiKey $apiKey -Repository $repoName -Tags ("Azure", "AzureRM") Write-Host "Published $module module" } -} -Unregister-PSRepository -Name $repoName \ No newline at end of file +} \ No newline at end of file From aafa531e565f844e478fe92560fda32b0f7c7699 Mon Sep 17 00:00:00 2001 From: stankovski Date: Fri, 25 Sep 2015 11:06:18 -0700 Subject: [PATCH 3/4] Fixed install script --- build.proj | 2 +- setup-powershellget/Setup/ShortcutStartup.ps1 | 21 +++++-------- tools/PublishModules.ps1 | 31 +++++++++---------- 3 files changed, 22 insertions(+), 32 deletions(-) diff --git a/build.proj b/build.proj index abe9a6ee424d..b49b13d339c6 100644 --- a/build.proj +++ b/build.proj @@ -289,7 +289,7 @@ - + diff --git a/setup-powershellget/Setup/ShortcutStartup.ps1 b/setup-powershellget/Setup/ShortcutStartup.ps1 index 9ff5d31478bc..f50ca1a4bf9a 100644 --- a/setup-powershellget/Setup/ShortcutStartup.ps1 +++ b/setup-powershellget/Setup/ShortcutStartup.ps1 @@ -26,26 +26,19 @@ Finalizing installation of Azure PowerShell. Installing Azure Modules from PowerShell Gallery. This may take some time... "@ + $env:PSModulePath = "$env:HOME\Documents\WindowsPowerShell\Modules;$env:ProgramFiles\WindowsPowerShell\Modules;$env:SystemRoot\system32\WindowsPowerShell\v1.0\Modules\" + Import-Module PackageManagement $result = Get-PackageProvider -Name NuGet -ForceBootstrap Import-Module PowerShellGet - $NuGetPublishingSource = $env:NuGetPublishingSource - if ([string]::IsNullOrWhiteSpace($NuGetPublishingSource)) { - Install-Module Azure - Write-Output "Azure $((Get-InstalledModule -Name Azure)[0].Version) installed..." - Install-Module AzureRM - Write-Output "AzureRM $((Get-InstalledModule -Name AzureRM)[0].Version) installed..." - Update-AzureRM - } else { - Install-Module Azure -Repository $NuGetPublishingSource - Write-Output "Azure $((Get-InstalledModule -Name Azure)[0].Version) installed..." - Install-Module AzureRM -Repository $NuGetPublishingSource - Write-Output "AzureRM $((Get-InstalledModule -Name AzureRM)[0].Version) installed..." - Update-AzureRM -Repository $NuGetPublishingSource - } + Install-Module Azure + Write-Output "Azure $((Get-InstalledModule -Name Azure)[0].Version) installed..." + Install-Module AzureRM + Write-Output "AzureRM $((Get-InstalledModule -Name AzureRM)[0].Version) installed..." + Update-AzureRM } else { cd c:\ $welcomeMessage = @" diff --git a/tools/PublishModules.ps1 b/tools/PublishModules.ps1 index ef28708f0d1c..c6e74e4ac62a 100644 --- a/tools/PublishModules.ps1 +++ b/tools/PublishModules.ps1 @@ -15,28 +15,25 @@ param( [Parameter(Mandatory = $false, Position = 0)] [string] $buildConfig, - [Parameter(Mandatory = $false, Position = 1)] + [Parameter(Mandatory = $false, Position = 1)] [string] $apiKey, - [Parameter(Mandatory = $false, Position = 2)] - [string] $repository + [Parameter(Mandatory = $false, Position = 2)] + [string] $repositoryLocation ) if ([string]::IsNullOrEmpty($buildConfig)) { - Write-Verbose "Setting build configuration to 'Release'" - $buildConfig = 'Release' + Write-Verbose "Setting build configuration to 'Release'" + $buildConfig = "Release" } if ([string]::IsNullOrEmpty($repositoryLocation)) { - Write-Verbose "Setting repository location to 'https://dtlgalleryint.cloudapp.net/api/v2'" + Write-Verbose "Setting repository location to 'https://dtlgalleryint.cloudapp.net/api/v2'" - $repository = 'https://dtlgalleryint.cloudapp.net' + $repositoryLocation = "https://dtlgalleryint.cloudapp.net/api/v2" } -$repositoryLocation = '$repository/api/v2/' -$repositoryPackageLocation = '$repository/api/v2/package' - $packageFolder = "$PSScriptRoot\..\src\Package" @@ -45,7 +42,7 @@ if ($repo -ne $null) { $repoName = $repo.Name } else { $repoName = $(New-Guid).ToString() - Register-PSRepository -Name $repoName -SourceLocation $repositoryLocation -PublishLocation $repositoryPackageLocation -InstallationPolicy Trusted + Register-PSRepository -Name $repoName -SourceLocation $repositoryLocation -PublishLocation $repositoryLocation/package -InstallationPolicy Trusted } $modulePath = "$packageFolder\$buildConfig\ServiceManagement\Azure" # Publish Azure module @@ -64,10 +61,10 @@ Write-Host "Published AzureRM.Profile module" # Publish AzureRM modules $resourceManagerModules = Get-ChildItem -Path "$packageFolder\$buildConfig\ResourceManager\AzureResourceManager" -Directory foreach ($module in $resourceManagerModules) { - if ($module -ne "AzureRM.Profile") { - $modulePath = $module.FullName - Write-Host "Publishing $module module from $modulePath" + if ($module -ne "AzureRM.Profile") { + $modulePath = $module.FullName + Write-Host "Publishing $module module from $modulePath" Publish-Module -Path $modulePath -NuGetApiKey $apiKey -Repository $repoName -Tags ("Azure", "AzureRM") - Write-Host "Published $module module" - } -} \ No newline at end of file + Write-Host "Published $module module" + } +} From 44704ab80a3935ab50f3d4d9f466be3a32e1c0d6 Mon Sep 17 00:00:00 2001 From: stankovski Date: Fri, 25 Sep 2015 11:34:28 -0700 Subject: [PATCH 4/4] Removed Install-Module Azure from the shortcut --- setup-powershellget/Setup/ShortcutStartup.ps1 | 5 +- tools/AzureRM/AzureRM.psm1 | 62 +++++++++---------- 2 files changed, 34 insertions(+), 33 deletions(-) diff --git a/setup-powershellget/Setup/ShortcutStartup.ps1 b/setup-powershellget/Setup/ShortcutStartup.ps1 index f50ca1a4bf9a..c8dafd9404e9 100644 --- a/setup-powershellget/Setup/ShortcutStartup.ps1 +++ b/setup-powershellget/Setup/ShortcutStartup.ps1 @@ -34,8 +34,6 @@ This may take some time... Import-Module PowerShellGet - Install-Module Azure - Write-Output "Azure $((Get-InstalledModule -Name Azure)[0].Version) installed..." Install-Module AzureRM Write-Output "AzureRM $((Get-InstalledModule -Name AzureRM)[0].Version) installed..." Update-AzureRM @@ -44,6 +42,9 @@ This may take some time... $welcomeMessage = @" For a list of all Azure cmdlets type 'help azure'. For a list of Azure Pack cmdlets type 'Get-Command *wapack*'. + +To use Azure Service Management cmdlets please execute the following cmdlet: + Install-Module Azure "@ Write-Output $welcomeMessage diff --git a/tools/AzureRM/AzureRM.psm1 b/tools/AzureRM/AzureRM.psm1 index 9b3e46003bad..5f14bb0197b2 100644 --- a/tools/AzureRM/AzureRM.psm1 +++ b/tools/AzureRM/AzureRM.psm1 @@ -1,29 +1,29 @@ -$AzureRMModules = ( - "Azure.Storage", - "AzureRM.ApiManagement", - "AzureRM.Automation", - "AzureRM.Backup", - "AzureRM.Batch", - "AzureRM.Compute", - "AzureRM.DataFactories", - "AzureRM.Dns", - "AzureRM.HDInsight", - "AzureRM.Insights", - "AzureRM.KeyVault", - "AzureRM.Network", - "AzureRM.OperationalInsights", - "AzureRM.Profile", - "AzureRM.RedisCache", - "AzureRM.Resources", - "AzureRM.SiteRecovery", - "AzureRM.Sql", - "AzureRM.Storage", - "AzureRM.StreamAnalytics", - "AzureRM.Tags", - "AzureRM.TrafficManager", - "AzureRM.UsageAggregates", - "AzureRM.Websites" -) +$AzureRMModules = @{ + "Azure.Storage" = "0.9.8"; + "AzureRM.ApiManagement" = "0.9.8"; + "AzureRM.Automation" = "0.9.8"; + "AzureRM.Backup" = "0.9.8"; + "AzureRM.Batch" = "0.9.8"; + "AzureRM.Compute" = "0.9.8"; + "AzureRM.DataFactories" = "0.9.8"; + "AzureRM.Dns" = "0.9.8"; + "AzureRM.HDInsight" = "0.9.8"; + "AzureRM.Insights" = "0.9.8"; + "AzureRM.KeyVault" = "0.9.8"; + "AzureRM.Network" = "0.9.8"; + "AzureRM.OperationalInsights" = "0.9.8"; + "AzureRM.Profile" = "0.9.8"; + "AzureRM.RedisCache" = "0.9.8"; + "AzureRM.Resources" = "0.9.8"; + "AzureRM.SiteRecovery" = "0.9.8"; + "AzureRM.Sql" = "0.9.8"; + "AzureRM.Storage" = "0.9.8"; + "AzureRM.StreamAnalytics" = "0.9.8"; + "AzureRM.Tags" = "0.9.8"; + "AzureRM.TrafficManager" = "0.9.8"; + "AzureRM.UsageAggregates" = "0.9.8"; + "AzureRM.Websites" = "0.9.8" +} <# .Synopsis @@ -41,12 +41,12 @@ $AzureRMModules = ( function Update-AzureRM { param( - [Parameter(Position=0, Mandatory = $false)] + [Parameter(Position=0; Mandatory = $false)] [string] - $Repository, + $Repository; - [Parameter(Position=1, Mandatory = $false)] - [ValidateSet("CurrentUser","AllUsers")] + [Parameter(Position=1; Mandatory = $false)] + [ValidateSet("CurrentUser";"AllUsers")] [string] $Scope) @@ -67,7 +67,7 @@ function Update-AzureRM } $v = (Get-InstalledModule -Name $args[0])[0].Version.ToString() Write-Output "$($args[0]) $v installed..." - } -ArgumentList $_, $Repository, $Scope } + } -ArgumentList $_; $Repository; $Scope } $AzureRMModules | ForEach {Get-Job -Name $_ | Wait-Job | Receive-Job } }