Skip to content

Rackspace CLI - Install the binary with a script #453

Description

@davecanderson

The Rackpsace CLI Installation and Configuration documentation includes a Powershell script to download and install the binary but this has the wrong -Uri parameter value.

Also the $DownloadPath variable is not used in all the correct places so changing the value assignment breaks the script. Better to provide the installation path as a parameter.

#requires -Version 3

[CmdletBinding()]
param
(  
    [Parameter(Position=0, HelpMessage='Specify Tools installation path')]
    [ValidateNotNullOrEmpty()]
    [string] $InstallPath = "C:\Tools"
)

Write-Output -InputObject "[$(Get-Date)] Status  :: Set the Tools Directory $InstallPath"
New-Item -Path $InstallPath -ItemType Directory -ErrorAction SilentlyContinue > $null
Set-Location -Path $InstallPath -ErrorAction SilentlyContinue

Write-Output -InputObject "[$(Get-Date)] Status  :: Download Rackspace CLI in $InstallPath"
Invoke-WebRequest -Uri 'https://ec4a542dbf90c03b9f75-b342aba65414ad802720b41e8159cf45.ssl.cf5.rackcdn.com/1.2/Windows/amd64/rack.exe' -Method Get -OutFile rack.exe

Write-Output -InputObject "[$(Get-Date)] Status  :: Unblock the executable file rack.exe"
Unblock-File -Path $("$InstallPath\rack.exe")

Write-Output -InputObject "[$(Get-Date)] Status  :: Permanently set the path $InstallPath to the Environment variable (Reboot required)."
[System.Environment]::SetEnvironmentVariable('Path', $env:Path + $InstallPath, [System.EnvironmentVariableTarget]::Machine)
Write-Output -InputObject "[$(Get-Date)] Status  :: Temporarily set the path $InstallPath to the Environment variable for immediate use in the current powershell session"
 $env:Path += ';' + $InstallPath

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions