PowerShell: Install / Uninstall
Powershell scripts to install/uninstall Falcon Sensor through the Falcon APIs on a Windows endpoint.
Table of Contents
Section titled “Table of Contents”- Falcon API Permissions
- Auto-Discovery of Falcon Cloud Region
- Configuration
- Install Sensor
- Uninstall Sensor
- Troubleshooting
Falcon API Permissions
Section titled “Falcon API Permissions”API clients are granted one or more API scopes. Scopes allow access to specific CrowdStrike APIs and describe the actions that an API client can perform.
Ensure the following API scopes are enabled:
- Install:
- Sensor Download [read]
- Sensor update policies [read]
- Uninstall:
- Host [write]
- Sensor update policies [write]
Auto-Discovery of Falcon Cloud Region
Section titled “Auto-Discovery of Falcon Cloud Region”The scripts support auto-discovery of the Falcon cloud region. If the FalconCloud parameter is not set, the script will attempt to auto-discover the cloud region. If you want to set the cloud region manually, or if your region does not support auto-discovery, you can set the FalconCloud parameter.
Configuration
Section titled “Configuration”Setting up Authentication
Section titled “Setting up Authentication”Using Client ID and Client Secret
Section titled “Using Client ID and Client Secret”Provide the required parameters:
.\falcon_windows_install.ps1 -FalconClientId <string> -FalconClientSecret <string>Using an Access Token
Section titled “Using an Access Token”You can also specify a Falcon access token if doing a batch install across multiple machines to prevent the need to call the token endpoint multiple times. If using an access token to authenticate, you MUST also provide FALCON_CLOUD:
.\falcon_windows_install.ps1 -FalconCloud us-2 -FalconAccessToken <string>Install Sensor
Section titled “Install Sensor”Uses the CrowdStrike Falcon APIs to check the sensor version assigned to a Windows Sensor Update policy,
downloads that version, then installs it on the local machine. By default, once complete, the script
deletes itself and the downloaded installer package. The individual steps and any related error messages
are logged to 'Windows\Temp\InstallFalcon.log' unless otherwise specified.
The script must be run as an administrator on the local machine in order for the Falcon Sensor installation to complete.
Script options can be passed as parameters or defined in the param() block. Default values are listed in the parameter descriptions:
<#.PARAMETER FalconCloudCrowdStrike Falcon OAuth2 API Hostname [default: autodiscover].PARAMETER FalconClientIdCrowdStrike Falcon OAuth2 API Client Id [Required if FalconAccessToken is not provided].PARAMETER FalconClientSecretCrowdStrike Falcon OAuth2 API Client Secret [Required if FalconAccessToken is not provided].PARAMETER FalconCidManually specify CrowdStrike Customer ID (CID) [default: $null].PARAMETER FalconAccessTokenManually set the access token for the Falcon API. Used to bypass the OAuth2 authentication process to cut down on rate limiting. [default: $null].PARAMETER GetAccessTokenReturns an access token from the API credentials provided. Used to manually set the FalconAccessToken parameter..PARAMETER MemberCidMember CID, used only in multi-CID ("Falcon Flight Control") configurations and with a parent management CID [default: $null].PARAMETER SensorUpdatePolicyNameSensor Update Policy name to check for assigned sensor version [default: 'platform_default'].PARAMETER InstallParamsAdditional Sensor installation parameters. Script parameters should be used instead when supported. [default: '/install /quiet /norestart' ].PARAMETER LogPathScript log location [default: 'Windows\Temp\InstallFalcon.log'].PARAMETER DeleteInstallerDelete sensor installer package when complete [default: $true].PARAMETER DeleteScriptDelete script when complete [default: $false].PARAMETER ProvTokenProvisioning token to use for sensor installation [default: $null].PARAMETER ProvWaitTimeTime to wait, in seconds, for sensor to provision [default: 1200].PARAMETER TagsA comma-separated list of tags to apply to the host after sensor installation [default: $null].PARAMETER ProxyHostThe proxy host for the sensor to use when communicating with CrowdStrike [default: $null].PARAMETER ProxyPortThe proxy port for the sensor to use when communicating with CrowdStrike [default: $null].PARAMETER ProxyDisableBy default, the Falcon sensor for Windows automatically attempts to use any available proxy connections when it connects to the CrowdStrike cloud.This parameter forces the sensor to skip those attempts and ignore any proxy configuration, including Windows Proxy Auto Detection..PARAMETER VerboseEnable verbose logging.PARAMETER FalconDebugPrint redacted progress markers: detected OS and PowerShell version, the exact sensorquery filter, how many installers matched and which was chosen, the API route and HTTPstatus for every call, and the sensor version installed plus the AID (that version is the one resolved fromthe policy or query, not re-read from the binary). Values are droppedunless the key is on a fixed allow-list, so secrets cannot appear. Also honors `$env:FALCON_DEBUG=1`.Do not use `Set-PSDebug -Trace` or the common `-Debug` parameter for support; they print credentials.#>To download the script:
Invoke-WebRequest -Uri https://raw.githubusercontent.com/crowdstrike/falcon-scripts/v1.14.0/powershell/install/falcon_windows_install.ps1 -OutFile falcon_windows_install.ps1Basic example that will install the sensor with the provided provisioning token
.\falcon_windows_install.ps1 -FalconClientId <string> -FalconClientSecret <string> -ProvToken <string>Uninstall Sensor
Section titled “Uninstall Sensor”Uninstalls the CrowdStrike Falcon Sensor for Windows. By default, once complete, the script
deletes itself and the downloaded uninstaller package (if necessary). The individual steps and any related error messages are logged to 'Windows\Temp\csfalcon_uninstall.log' unless otherwise specified.
The script must be run as an administrator on the local machine in order for the Falcon Sensor installation to complete.
Script options can be passed as parameters or defined in the param() block. Default values are listed in the parameter descriptions:
<#.PARAMETER MaintenanceTokenSensor uninstall maintenance token. If left undefined, the script will attempt to retrieve the token from the API assuming the FalconClientId|FalconClientSecret are defined..PARAMETER UninstallParamsSensor uninstall parameters ['/uninstall /quiet' if left undefined]. Note: '/uninstall' parameter is automatically removed when UninstallTool='standalone' as it's incompatible with CsUninstallTool.exe..PARAMETER UninstallToolSensor uninstall tool, local installation cache or CS standalone uninstaller ['installcache' if left undefined].PARAMETER LogPathScript log location ['Windows\Temp\csfalcon_uninstall.log' if left undefined].PARAMETER DeleteUninstallerDelete sensor uninstaller package when complete [default: $true].PARAMETER DeleteScriptDelete script when complete [default: $false].PARAMETER RemoveHostRemove host from CrowdStrike Falcon [requires either FalconClientId|FalconClientSecret or FalconAccessToken]. It is recommended to use Host Retention Policies to remove hosts from the Falcon console instead of this parameter..PARAMETER FalconCloudCrowdStrike Falcon OAuth2 API Hostname [default: autodiscover].PARAMETER FalconClientIdCrowdStrike Falcon OAuth2 API Client Id.PARAMETER FalconClientSecretCrowdStrike Falcon OAuth2 API Client Secret.PARAMETER FalconAccessTokenManually set the access token for the Falcon API. Used to bypass the OAuth2 authentication process to cut down on rate limiting. [default: $null].PARAMETER GetAccessTokenReturns an access token from the API credentials provided. Used to manually set the FalconAccessToken parameter..PARAMETER MemberCidMember CID, used only in multi-CID ("Falcon Flight Control") configurations and with a parent management CID..PARAMETER ProxyHostThe proxy host for the sensor to use when communicating with CrowdStrike [default: $null].PARAMETER ProxyPortThe proxy port for the sensor to use when communicating with CrowdStrike [default: $null].PARAMETER VerboseEnable verbose logging.PARAMETER FalconDebugPrint redacted progress markers: detected OS and PowerShell version, the exact sensorquery filter, how many installers matched and which was chosen, the API route and HTTPstatus for every call, and the sensor version installed plus the AID (that version is the one resolved fromthe policy or query, not re-read from the binary). Values are droppedunless the key is on a fixed allow-list, so secrets cannot appear. Also honors `$env:FALCON_DEBUG=1`.Do not use `Set-PSDebug -Trace` or the common `-Debug` parameter for support; they print credentials.#>To download the script:
Invoke-WebRequest -Uri https://raw.githubusercontent.com/crowdstrike/falcon-scripts/v1.14.0/powershell/install/falcon_windows_uninstall.ps1 -OutFile falcon_windows_uninstall.ps1Basic example that will uninstall the sensor with the provided maintenance token
.\falcon_windows_uninstall.ps1 -MaintenanceToken <string>Troubleshooting
Section titled “Troubleshooting”Use the redacted debug mode. It prints the detected OS and PowerShell version, the exact sensor query filter, how many installers matched and which was chosen, the API route and HTTP status for every call, and the sensor version installed plus the AID (the version is the one resolved from the policy or query, not re-read from the binary). Values are dropped unless the key is on a fixed allow-list, so credentials cannot appear in the output you send to support.
.\falcon_windows_install.ps1 -FalconDebug -FalconClientId <string> -FalconClientSecret <string> -ProvToken <string>Sample output from a real install on Windows PowerShell 5.1 (values from a live run, credentials never appear):
FALCON_DEBUG: start version=1.14.0 (PowerShell 5.1.20348.5499 Desktop) cloud=us-2 client_id_set=yes client_secret_set=yes access_token_set=no member_cid_set=no proxy_set=no policy_name_set=noFALCON_DEBUG: environment os=windows os_version=10.0.20348.0 os_arch=AMD64 run_as=adminFALCON_DEBUG: Invoke-FalconAuth step=response http_status=201 cloud=us-2FALCON_DEBUG: GetPolicy step=query path=/policy/combined/sensor-update/v2 filter=platform_name:'Windows'+name.raw:'platform_default'FALCON_DEBUG: GetPolicy step=resolved policy_version=8.10.21405FALCON_DEBUG: GetInstaller step=query path=/sensors/combined/installers/v3 filter=platform:'windows'+version:'8.10.21405' sort=noneFALCON_DEBUG: GetInstaller step=matched count=1FALCON_DEBUG: GetInstaller step=selected index=0 file_type=exe sha=338d1b7f2508FALCON_DEBUG: DownloadFile step=downloaded installer=C:\Windows\Temp\FalconSensor_Windows.exe bytes=131724104FALCON_DEBUG: Installer step=configure cid_source=api provisioning_token_set=no tags_count=0 proxy_set=noFALCON_DEBUG: InstallerProcess step=installed version=8.10.21405 aid=61c06e35b3104b99a371be2d6943d2e7$env:FALCON_DEBUG = '1' does the same thing, which is useful when the script runs
from a job where you cannot add a parameter.
-Verbose still enables the script’s own operational logging in the console and the
log file. It is not a replacement for -FalconDebug.
Note: debug markers go to the console via
Write-Host, so they are not written to the script’s log file. AStart-Transcriptsession does capture them, so stop any transcript first if you do not want the markers on disk.
Do not use Set-PSDebug -Trace or the common -Debug parameter for support.
Tracing prints every statement with its arguments, including FalconClientSecret,
ProvToken, access tokens, Authorization headers and the OAuth request body. These
scripts call Set-PSDebug -Off on entry, but that runs after PowerShell binds the
parameters, so a trace started beforehand can still expose the values you passed in.