Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rackspace CLI - Install the binary with a script #453

Open
davecanderson opened this issue Apr 18, 2017 · 0 comments
Open

Rackspace CLI - Install the binary with a script #453

davecanderson opened this issue Apr 18, 2017 · 0 comments

Comments

@davecanderson
Copy link

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant