Overview
PSFalcon uses OAuth2 client credentials for authentication. These cmdlets manage the token lifecycle and credential caching for seamless API access.All API operations require a valid OAuth2 access token. Use
Request-FalconToken before making any API calls.Request-FalconToken
Request an OAuth2 access token using your API credentials.Parameters
OAuth2 client identifier (32-character hexadecimal)Pattern:
^[a-fA-F0-9]{32}$Aliases: client_idIf not provided, you will be prompted to enter it interactively.OAuth2 client secret (40-character alphanumeric)Pattern:
^\w{40}$Aliases: client_secretIf not provided, you will be prompted to enter it interactively.CrowdStrike cloud regionValid values:
us-1- US Commercial 1 (default)us-2- US Commercial 2eu-1- EU Cloudus-gov-1- US GovCloud 1us-gov-2- US GovCloud 2
Hostname value.CrowdStrike API hostname (alternative to
Cloud parameter)Valid values:https://api.crowdstrike.com(us-1)https://api.us-2.crowdstrike.com(us-2)https://api.eu-1.crowdstrike.com(eu-1)https://api.laggar.gcw.crowdstrike.com(us-gov-1)https://api.us-gov-2.crowdstrike.mil(us-gov-2)
Cloud parameter for simpler syntax unless you need direct hostname control.Custom API URL for module troubleshootingUsed for testing or custom deployments. Overrides the
Hostname parameter.Member CID for multi-CID authentication (Falcon Flight Control)Pattern:
^[a-fA-F0-9]{32}(-\w{2})?$Aliases: cid, member_cidUsed when authenticating from a parent CID to access a child CID’s resources.Event collector configuration for logging token requestsRequired keys:
Uri- LogScale/Humio ingest endpointToken- Ingest token
Enable- Enable event collection (boolean)
Register-FalconEventCollector for audit logging.Behavior
Credential Caching:- Stores
ClientId,ClientSecret,Hostname, andMemberCidfor re-use - Caches the OAuth2 access token with expiration timestamp
- Automatically requests a new token when current token expires in < 240 seconds
- Automatically follows redirects to the correct cloud region
- Updates cached hostname if redirected (indicated by
X-Cs-Regionheader)
- Automatically sets TLS 1.2 for secure communication
- Supports both
[System.Net.Http.HttpClientHandler]and[Net.ServicePointManager]
Examples
Revoke-FalconToken
Revoke your active OAuth2 access token and clear cached credentials.Description
Revokes the current OAuth2 access token at the CrowdStrike API and clears all cached credential information from the module, including:- OAuth2 access token
ClientIdClientSecretMemberCid
Request-FalconToken again to authenticate.
Parameters
This cmdlet has no parameters.Examples
Show-FalconToken
Display your current OAuth2 access token value.Description
Returns the current OAuth2 access token string (without theBearer prefix). Useful for debugging or using the token outside PSFalcon.
Parameters
This cmdlet has no parameters.Output
Returns the access token as a string, or throws an error if no token is available.Examples
Test-FalconToken
Display OAuth2 access token status and cached credential information.Description
Returns a[PSCustomObject] containing token status and cached credential information without exposing sensitive values.
Parameters
This cmdlet has no parameters.Output
Returns an object with the following properties:$true if a valid token exists and expires in > 240 seconds, otherwise $falseCached CrowdStrike API hostname
Cached OAuth2 client identifier
Cached member CID (if applicable)
Examples
Authentication Workflow
Automatic Token Refresh
PSFalcon automatically refreshes your token when it expires in < 240 secondsNo action required - happens transparently during API calls
Best Practices
Secure Credential Storage
Secure Credential Storage
Never hardcode credentials in scripts. Use secure storage methods:Or use environment variables:
Token Lifecycle Management
Token Lifecycle Management
- Tokens are valid for 30 minutes by default
- PSFalcon auto-refreshes tokens expiring in < 4 minutes
- Revoke tokens when switching contexts or ending sessions
- Use
Test-FalconTokento verify authentication state
Multi-CID Environments
Multi-CID Environments
In Falcon Flight Control (multi-CID) environments:
Error Handling
Error Handling
Always handle authentication errors gracefully:
Troubleshooting
Invalid Client Credentials
Invalid Client Credentials
Error:
Cannot validate argument on parameter "ClientId"Solution: Ensure ClientId is exactly 32 hexadecimal characters and ClientSecret is exactly 40 alphanumeric characters.Wrong Cloud/Region
Wrong Cloud/Region
Symptom: HTTP 308 redirects or connection failuresSolution: Verify you’re using the correct
Cloud parameter for your API credentials:- US Commercial customers:
us-1orus-2 - EU customers:
eu-1 - GovCloud customers:
us-gov-1orus-gov-2
Token Expired
Token Expired
Error:
No access token availableSolution: Run Request-FalconToken again. If credentials are cached, no parameters are needed.MemberCid Invalid
MemberCid Invalid
Error:
Cannot validate argument on parameter "MemberCid"Solution: Verify MemberCid format matches ^[a-fA-F0-9]{32}(-\w{2})?$Related Resources
CrowdStrike API Documentation
Official API documentation and OAuth2 reference
PSFalcon Wiki
Community examples and detailed guides