2024-11-08 12:38:20 +01:00
|
|
|
The *install-salesforce-cli.ps1* Script
|
|
|
|
===========================
|
2024-08-15 09:51:46 +02:00
|
|
|
|
|
|
|
This PowerShell script downloads and installs the Salesforce CLI on Windows.
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
----------
|
|
|
|
```powershell
|
2024-11-08 12:35:11 +01:00
|
|
|
/home/markus/Repos/PowerShell/scripts/install-salesforce-cli.ps1 [<CommonParameters>]
|
2024-08-15 09:51:46 +02:00
|
|
|
|
|
|
|
[<CommonParameters>]
|
|
|
|
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
|
|
|
|
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
|
|
|
|
```
|
|
|
|
|
|
|
|
Example
|
|
|
|
-------
|
|
|
|
```powershell
|
|
|
|
PS> ./install-salesforce-cli.ps1
|
|
|
|
(The Salesforce CLI installer will be downloaded and run.)
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
Notes
|
|
|
|
-----
|
|
|
|
Author: Gavin R. McDavitt
|
|
|
|
|
|
|
|
Related Links
|
|
|
|
-------------
|
|
|
|
https://github.com/fleschutz/PowerShell
|
|
|
|
|
|
|
|
Script Content
|
|
|
|
--------------
|
|
|
|
```powershell
|
|
|
|
<#
|
|
|
|
.SYNOPSIS
|
|
|
|
Installs the Salesforce CLI (sfdx).
|
|
|
|
.DESCRIPTION
|
|
|
|
This PowerShell script downloads and installs the Salesforce CLI on Windows.
|
|
|
|
.EXAMPLE
|
|
|
|
PS> ./install-salesforce-cli.ps1
|
|
|
|
(The Salesforce CLI installer will be downloaded and run.)
|
|
|
|
.LINK
|
|
|
|
https://github.com/fleschutz/PowerShell
|
|
|
|
.NOTES
|
|
|
|
Author: Gavin R. McDavitt
|
|
|
|
#>
|
|
|
|
|
|
|
|
try {
|
|
|
|
# Define the URL of the Salesforce CLI installer
|
|
|
|
$url = "https://developer.salesforce.com/media/salesforce-cli/sf/channels/stable/sf-x64.exe"
|
|
|
|
|
|
|
|
# Define the output path for the downloaded installer
|
|
|
|
$output = "$env:USERPROFILE\Downloads\sfdx-windows-x64.exe"
|
|
|
|
|
|
|
|
# Download the installer
|
|
|
|
Invoke-WebRequest -Uri $url -OutFile $output
|
|
|
|
|
|
|
|
# Run the installer
|
|
|
|
Start-Process -FilePath $output -ArgumentList "/silent" -Wait
|
|
|
|
|
|
|
|
# Verify the installation
|
|
|
|
sfdx --version
|
|
|
|
Write-Output "Salesforce CLI installed successfully."
|
|
|
|
|
|
|
|
exit 0 # success
|
|
|
|
} catch {
|
|
|
|
Write-Output "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2024-11-08 12:40:31 +01:00
|
|
|
*(generated by convert-ps2md.ps1 as of 11/08/2024 12:40:17)*
|