More changes to make platform-agnostic
This commit is contained in:
@@ -88,9 +88,9 @@ ForEach ($Uri in $AddonUris) {
|
||||
$UriStatusCode = (Invoke-WebRequest -Uri $Uri -UseBasicParsing -Method Head -SkipHttpErrorCheck).StatusCode
|
||||
If ($UriStatusCode -eq 200) {
|
||||
Try {
|
||||
Invoke-WebRequest -Uri $Uri -OutFile "$Env:Temp\$(Split-Path -Path $Uri -Leaf)" -ErrorAction Stop
|
||||
Invoke-WebRequest -Uri $Uri -OutFile "$([System.IO.Path]::GetTempPath())\$(Split-Path -Path $Uri -Leaf)" -ErrorAction Stop
|
||||
Write-Host "Importing addon: $(Split-Path -Path $Uri -Leaf)"
|
||||
Import-Module -Name "$Env:Temp\$(Split-Path -Path $Uri -Leaf)" -Force
|
||||
Import-Module -Name "$([System.IO.Path]::GetTempPath())\$(Split-Path -Path $Uri -Leaf)" -Force
|
||||
}
|
||||
Catch {
|
||||
Write-Host "Error encountered importing addon"
|
||||
@@ -102,6 +102,8 @@ ForEach ($Uri in $AddonUris) {
|
||||
Exit $UriStatusCode
|
||||
}
|
||||
}
|
||||
|
||||
Import-Modules $ModuleNames
|
||||
#endregion Imports
|
||||
|
||||
#region Functions
|
||||
@@ -131,24 +133,6 @@ If (-Not $NoLog) {
|
||||
}
|
||||
Add-LogEntry (Start-Transcript "$LogDir\$ThisScript.log" -Append)
|
||||
}
|
||||
|
||||
# Load any modules required by script
|
||||
If ($ModuleNames) {
|
||||
Initialize-PSGallery
|
||||
ForEach ($Module in $ModuleNames) {
|
||||
If (-Not (Get-Module -ListAvailable -Name $Module)) {
|
||||
Try {
|
||||
Add-LogEntry "Module `"$Module`" not found, installing"
|
||||
Install-Module -Name $Module -Scope CurrentUser -Force -AllowClobber
|
||||
}
|
||||
Catch {
|
||||
Add-LogEntry "Module failed to install automatically! Manaully install the module, then re-run the script." -As Error
|
||||
Exit 1
|
||||
}
|
||||
}
|
||||
Import-Module $Module
|
||||
}
|
||||
}
|
||||
#endregion Prep
|
||||
|
||||
#region Execution
|
||||
|
Reference in New Issue
Block a user