From 699fc874f1a292b1b88a161de676c03f27082cb2 Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Thu, 15 Aug 2024 09:27:53 +0200 Subject: [PATCH] Added install-salesforce-cli.ps1 --- scripts/install-salesforce-cli.ps1 | 32 ++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 scripts/install-salesforce-cli.ps1 diff --git a/scripts/install-salesforce-cli.ps1 b/scripts/install-salesforce-cli.ps1 new file mode 100644 index 00000000..36e5dcb1 --- /dev/null +++ b/scripts/install-salesforce-cli.ps1 @@ -0,0 +1,32 @@ +<# +.SYNOPSIS + Installs the Salesforce CLI (sfdx) on Windows. +.DESCRIPTION + This PowerShell script downloads and installs the Salesforce CLI. +.EXAMPLE + PS> ./install-salesforce-cli.ps1 + (The Salesforce CLI installer will be downloaded and run.) +#> + +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 +} \ No newline at end of file