Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
peppekerstens committed Jul 30, 2019
1 parent d4bcf4e commit dd7dcc0
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions Utility/ARM/New-OnPremiseHybridWorker.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<#PSScriptInfo
.VERSION 1.6
.VERSION 1.7
.GUID b6ad1d8e-263a-46d6-882b-71592d6e166d
Expand All @@ -26,6 +26,10 @@
.RELEASENOTES
1.7 - 7/30/2019
-- MODIFIED BY Peppe Kerstens
-- #54 Fixed source assumption.
1.6 - 11/15/2018
-- MODIFIED BY Alexander Zabielski
-- Updated the parameters to accept a TenantID to pass to the connection params.
Expand Down Expand Up @@ -136,9 +140,9 @@
AUTHOR: Jenny Hunter, Azure Automation Team
LASTEDIT: May 29, 2018
LASTEDIT: July 30 2019
EDITBY: Jenny Hunter
EDITBY: Peppe Kerstens
#>

Expand Down Expand Up @@ -184,13 +188,16 @@ $ErrorActionPreference = "Stop"
Write-Output "Importing necessary modules..."

# Create a list of the modules necessary to register a hybrid worker
$AzureRmModule = @{"Name" = "AzureRM"; "Version" = ""}
$AzureRmModule = @{"Name" = "AzureRM"; "Version" = ""; "Repository" = "PSGallery"}
$Modules = @($AzureRmModule)

# Import modules
foreach ($Module in $Modules) {

$ModuleName = $Module.Name
$splatRepository = @{}
If ($Module.Repository) {$splatRepository.Repository = $Module.Repository}


# Find the module version
if ([string]::IsNullOrEmpty($Module.Version)){
Expand All @@ -205,11 +212,11 @@ foreach ($Module in $Modules) {
}

# Check if the required module is already installed
$CurrentModule = Get-Module -Name $ModuleName -ListAvailable | where "Version" -eq $ModuleVersion
$CurrentModule = Get-Module -Name $ModuleName -ListAvailable | Where-Object "Version" -eq $ModuleVersion

if (!$CurrentModule) {

$null = Install-Module -Name $ModuleName -RequiredVersion $ModuleVersion -Force
$null = Install-Module -Name $ModuleName -RequiredVersion $ModuleVersion @splatRepository -Force
Write-Output " Successfully installed version $ModuleVersion of $ModuleName..."

} else {
Expand Down

0 comments on commit dd7dcc0

Please sign in to comment.