diff --git a/setup-powershellget/Setup/ShortcutStartup.ps1 b/setup-powershellget/Setup/ShortcutStartup.ps1 index fed332e89acc..c8dafd9404e9 100644 --- a/setup-powershellget/Setup/ShortcutStartup.ps1 +++ b/setup-powershellget/Setup/ShortcutStartup.ps1 @@ -26,20 +26,25 @@ 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 - Get-PackageProvider -Name NuGet -ForceBootstrap + + $result = Get-PackageProvider -Name NuGet -ForceBootstrap + + Import-Module PowerShellGet - $NuGetPublishingSource = $env:NuGetPublishingSource - if ([string]::IsNullOrWhiteSpace($NuGetPublishingSource)) { - Install-Module AzureRM -Repository $NuGetPublishingSource - } else { - Install-Module AzureRM - } + Install-Module AzureRM + Write-Output "AzureRM $((Get-InstalledModule -Name AzureRM)[0].Version) installed..." + Update-AzureRM } else { cd c:\ $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 dbcfdd49a92b..5f14bb0197b2 100644 --- a/tools/AzureRM/AzureRM.psm1 +++ b/tools/AzureRM/AzureRM.psm1 @@ -1,3 +1,30 @@ +$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 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 diff --git a/tools/PublishModules.ps1 b/tools/PublishModules.ps1 index e8535c77ebc7..c6e74e4ac62a 100644 --- a/tools/PublishModules.ps1 +++ b/tools/PublishModules.ps1 @@ -15,32 +15,43 @@ 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)] + [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 'http://psget/PSGallery/api/v2/'" - $repositoryLocation = 'http://psget/PSGallery/api/v2/' + Write-Verbose "Setting repository location to 'https://dtlgalleryint.cloudapp.net/api/v2'" + + $repositoryLocation = "https://dtlgalleryint.cloudapp.net/api/v2" } + $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 $repositoryLocation/package -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" @@ -50,11 +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" - Publish-Module -Path $modulePath -NuGetApiKey $apiKey -Repository $repoName - Write-Host "Published $module module" - } + 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" + } } -Unregister-PSRepository -Name $repoName \ No newline at end of file