Beyond Salesforce CLI
psfdx offers commands that go beyond the plain Salesforce CLI, building on the wider PowerShell library to offer time-saving helpers such as Watch commands and org comparisons.
Watch commands
Run it in your project and leave it running. Watch-SalesforceApex deploys each Apex class or trigger when you save it and runs the tests that reference it. Watch-SalesforceJest re-runs your LWC Jest tests when files change.
PS> Watch-SalesforceApex
PS> Watch-SalesforceJestWatch-SalesforceApex deploys to the default target org. Press Ctrl+C to stop.
Compare orgs
One row per difference between two orgs. Read-only.
PS> Compare-SalesforceFields -SourceOrg uat -TargetOrg prod -ObjectName Account, Opportunity |
Format-Table ObjectName, FieldName, Difference, Property, SourceValue, TargetValue
ObjectName FieldName Difference Property SourceValue TargetValue
---------- --------- ---------- -------- ----------- -----------
Account Customer_Tier__c Changed PicklistValues ["Gold","Platinum","Silver"] ["Gold","Silver"]
Account Region__c MissingInTarget Type picklist
Opportunity Discount_Percent__c Changed Precision 5 3
Opportunity Partner_Code__c Changed Length 20 10
Opportunity Partner_Code__c Changed Nillable true falseIllustrative output from made-up orgs.
Also Compare-SalesforcePermissions (what permission sets grant, not a user's effective access) and Compare-SalesforceMetadata (content support varies by metadata type).
Aggregate Apex coverage
Combined coverage for each class and trigger, from every test run in the org.
PS> Get-SalesforceCodeCoverage -Aggregate -Threshold 75 -TargetOrg my-sandbox |
Sort-Object CoveragePercent |
Format-Table Name, Type, NumLinesCovered, NumLinesUncovered, CoveragePercent
Name Type NumLinesCovered NumLinesUncovered CoveragePercent
---- ---- --------------- ----------------- ---------------
InvoiceService ApexClass 41 59 41.00
OpportunityTrigger ApexTrigger 12 8 60.00
DiscountCalculator ApexClass 88 32 73.33Illustrative output from a made-up org.
The threshold is a diagnostic filter, not a check that a deployment will pass.
Limits and thresholds
Every org limit with Used and UsedPercent added. -Threshold keeps the ones at or above a percentage.
PS> Get-SalesforceLimits -TargetOrg prod -Threshold 80Unknown values remain unknown: a limit with no maximum has no percentage.
Field and flow inventories
One flat row per field, and one row per flow with its active version and any newer draft.
PS> Get-SalesforceFieldInventory -ObjectName Account -CustomOnly -TargetOrg dev1
PS> Get-SalesforceFlows -ActiveOnly -TargetOrg dev1Deployment summaries
One flat object with a deployment's status, counts, failures and coverage gaps. A failed deployment is summarised, not thrown.
PS> Get-SalesforceDeploySummary -UseMostRecent -TargetOrg dev1Pipelines and safe previews
Query results are objects, so they pipe straight into commands that change records. -WhatIf shows what would change without changing it.
PS> Select-SalesforceRecords -Query "SELECT Id FROM Account WHERE Name = 'Old'" |
Set-SalesforceRecord -Type Account -FieldUpdates "Name='New'" -WhatIf
What if: Performing the operation "Update record" on target "Account 001000000000001AAA".
What if: Performing the operation "Update record" on target "Account 001000000000002AAA".Illustrative output from a made-up org.
Agent Skill
Gives Claude Code and compatible agents the psfdx command for everyday Salesforce tasks, with rules for confirming the org and asking before changes. Install the Agent Skill.
And there's more...
Every custom psfdx command: those that do more than run a single Salesforce CLI command. The module reference documents every command.
psfdx
Connect-SalesforceApi
Synopsis
Gets an access token for the Salesforce REST API with the username-password OAuth flow.
Syntax
Connect-SalesforceApi [-TargetOrg] <String> [-Password] <Object> [-Token] <Object> [-ClientId] <String> [-ClientSecret] <Object> [-Sandbox] [[-CustomUrl] <String>] [<CommonParameters>]Description
Does not use the Salesforce CLI. It posts the user name, the password plus security token, and the connected app client ID and secret to the org's /services/oauth2/token endpoint with Invoke-RestMethod and returns the response, which holds the access token and instance URL. The request is sent only over https. Pass the password, token and client secret as SecureString: they are converted to text only when the request is built and are never written to the verbose, debug or error output. Plain strings still work but write a warning, because they stay in your session history and memory.
Parameters
-TargetOrgString, required- The Salesforce user name to log in as (sent as the OAuth username). This is not an org alias. Required.
-PasswordObject, required- The user's password, as a SecureString (preferred) or a plain string (deprecated, writes a warning). The security token is appended to it. Required.
-TokenObject, required- The user's security token, as a SecureString (preferred) or a plain string (deprecated, writes a warning). Appended to the password. Required.
-ClientIdString, required- Consumer key of the connected app used for the login. Required.
-ClientSecretObject, required- Consumer secret of the connected app, as a SecureString (preferred) or a plain string (deprecated, writes a warning). Required.
-Sandboxswitch- Use the sandbox login host https://test.salesforce.com instead of https://login.salesforce.com.
-CustomUrlString- Base URL of the login host to use instead, for example a My Domain. It must be an absolute https:// URL, otherwise the cmdlet stops before sending anything.
Salesforce CLI
No direct Salesforce CLI command.
Examples
PS> Connect-SalesforceApi -TargetOrg [email protected] -Password $pw -Token $tok -ClientId $key -ClientSecret $secretRequest an access token from production.
Remarks
- To see the examples, type: "Get-Help Connect-SalesforceApi -Examples"
- For more information, type: "Get-Help Connect-SalesforceApi -Detailed"
- For technical information, type: "Get-Help Connect-SalesforceApi -Full"
- For online help, type: "Get-Help Connect-SalesforceApi -Online"
Related Links
ConvertTo-SalesforceSoqlDateTime
Synopsis
Formats a DateTime as a SOQL datetime literal in UTC, for example 2026-11-18T11:00:00Z.
Syntax
ConvertTo-SalesforceSoqlDateTime [-Value] <DateTime> [[-TimeZone] <TimeZoneInfo>] [<CommonParameters>]Description
Formats a DateTime as a SOQL datetime literal in UTC, for example 2026-11-18T11:00:00Z. It is not quoted.
The value is converted to UTC before the Z is written, so the literal is the same instant whatever the machine's time zone: Kind Utc used as it is Kind Local converted from the machine's local time zone, including daylight saving time Kind Unspecified treated as local time, the same as .NET's ToUniversalTime() does. A date parsed from text such as '2026-11-18 12:00' is Unspecified, so it means 12:00 where you are. -TimeZone names the zone to read a Local or Unspecified value in instead of the machine's. A time that does not exist in that zone (the hour skipped when the clocks go forward) is refused. A time that happens twice (the hour repeated when the clocks go back) is read as standard time, as .NET does. Fractions of a second are dropped, as the old 's' format did. 's' is culture-invariant.
Parameters
-ValueDateTime, required- The date and time to format. A Local or Unspecified kind is read as local time and converted to UTC. Accepts pipeline input. Required. Accepts input from the pipeline.
-TimeZoneTimeZoneInfo- Time zone to read an unspecified value in, for example Europe/London, instead of the computer's zone.
Salesforce CLI
No direct Salesforce CLI command.
Examples
PS> ConvertTo-SalesforceSoqlDateTime -Value my-orgRuns ConvertTo-SalesforceSoqlDateTime with its required parameters.
Remarks
- To see the examples, type: "Get-Help ConvertTo-SalesforceSoqlDateTime -Examples"
- For more information, type: "Get-Help ConvertTo-SalesforceSoqlDateTime -Detailed"
- For technical information, type: "Get-Help ConvertTo-SalesforceSoqlDateTime -Full"
- For online help, type: "Get-Help ConvertTo-SalesforceSoqlDateTime -Online"
Related Links
ConvertTo-SalesforceSoqlIdentifier
Synopsis
Checks that a value is a plain Salesforce object or field API name (letters, digits and underscores, starting with a letter, with optional dots for relationships) and returns it.
Syntax
ConvertTo-SalesforceSoqlIdentifier [-Value] <String> [<CommonParameters>]Description
Checks that a value is a plain Salesforce object or field API name (letters, digits and underscores, starting with a letter, with optional dots for relationships) and returns it. Identifiers cannot be quoted in SOQL, so anything else is refused instead of being placed in the query.
Parameters
-ValueString, required- An object or field API name (letters, digits and underscores, with optional dots for relationships). Anything else makes the cmdlet throw. Accepts pipeline input. Required. Accepts input from the pipeline.
Salesforce CLI
No direct Salesforce CLI command.
Examples
PS> ConvertTo-SalesforceSoqlIdentifier -Value my-orgRuns ConvertTo-SalesforceSoqlIdentifier with its required parameters.
Remarks
- To see the examples, type: "Get-Help ConvertTo-SalesforceSoqlIdentifier -Examples"
- For more information, type: "Get-Help ConvertTo-SalesforceSoqlIdentifier -Detailed"
- For technical information, type: "Get-Help ConvertTo-SalesforceSoqlIdentifier -Full"
- For online help, type: "Get-Help ConvertTo-SalesforceSoqlIdentifier -Online"
Related Links
ConvertTo-SalesforceSoqlLiteral
Synopsis
Turns a value into a quoted SOQL string literal that is safe to place in a generated query.
Syntax
ConvertTo-SalesforceSoqlLiteral [-Value] <String> [-Like] [<CommonParameters>]Description
Turns a value into a quoted SOQL string literal that is safe to place in a generated query.
SOQL escapes a string with a backslash, not by doubling the quote: O'Brien is 'O\'Brien'. Backslash, apostrophe and double quote are escaped. Line breaks, tabs, backspace and form feed become \n \r \t \b \f, so a value never puts a real line break into the query. Any other control character is refused rather than guessed at. Unicode text is kept as it is.
With -Like, % and _ are escaped as well so they match themselves; without it they are left alone, because they are ordinary characters in an = comparison.
The result is also safe inside the double-quoted --query "..." argument that psfdx builds: a double quote or a backtick gets the command-line escape that ConvertTo-PsfdxArgumentList understands. Caller-authored queries passed to Select-SalesforceRecords -Query are not touched by this.
Parameters
-ValueString, required- The text to turn into a quoted SOQL string. Quotes and backslashes are escaped; control characters other than line breaks and tabs are refused. Accepts pipeline input. Required. Accepts input from the pipeline.
-Likeswitch- Also escape % and _ so they match themselves inside a LIKE pattern.
Salesforce CLI
No direct Salesforce CLI command.
Examples
PS> ConvertTo-SalesforceSoqlLiteral -Value my-orgRuns ConvertTo-SalesforceSoqlLiteral with its required parameters.
Remarks
- To see the examples, type: "Get-Help ConvertTo-SalesforceSoqlLiteral -Examples"
- For more information, type: "Get-Help ConvertTo-SalesforceSoqlLiteral -Detailed"
- For technical information, type: "Get-Help ConvertTo-SalesforceSoqlLiteral -Full"
- For online help, type: "Get-Help ConvertTo-SalesforceSoqlLiteral -Online"
Related Links
Get-SalesforceApiUsage
Synopsis
Shows how much of the daily API request limit an org has used.
Syntax
Get-SalesforceApiUsage [[-TargetOrg] <String>] [<CommonParameters>]Description
Reads the org limits with Get-SalesforceLimits and returns the DailyApiRequests entry with a Usage percentage added (used divided by max). Returns nothing if the org does not report that limit.
Parameters
-TargetOrgString- Username or alias of the org to check. If omitted, the Salesforce CLI uses the default target org (passed on to Get-SalesforceLimits).
Salesforce CLI
No direct Salesforce CLI command.
Examples
PS> Get-SalesforceApiUsage -TargetOrg prodSee the API usage of the production org.
Remarks
- To see the examples, type: "Get-Help Get-SalesforceApiUsage -Examples"
- For more information, type: "Get-Help Get-SalesforceApiUsage -Detailed"
- For technical information, type: "Get-Help Get-SalesforceApiUsage -Full"
- For online help, type: "Get-Help Get-SalesforceApiUsage -Online"
Related Links
Get-SalesforceDataStorage
Synopsis
Shows how much data storage an org has used.
Syntax
Get-SalesforceDataStorage [[-TargetOrg] <String>] [<CommonParameters>]Description
Reads the org limits with Get-SalesforceLimits and returns the DataStorageMB entry with InUse and Usage (percentage) added. Returns nothing if the org does not report that limit.
Parameters
-TargetOrgString- Username or alias of the org to check. If omitted, the Salesforce CLI uses the default target org (passed on to Get-SalesforceLimits).
Salesforce CLI
No direct Salesforce CLI command.
Examples
PS> Get-SalesforceDataStorage -TargetOrg prodData storage used, in MB and as a percentage.
Remarks
- To see the examples, type: "Get-Help Get-SalesforceDataStorage -Examples"
- For more information, type: "Get-Help Get-SalesforceDataStorage -Detailed"
- For technical information, type: "Get-Help Get-SalesforceDataStorage -Full"
- For online help, type: "Get-Help Get-SalesforceDataStorage -Online"
Related Links
Get-SalesforceDateTime
Synopsis
Formats a date and time as a SOQL datetime literal.
Syntax
Get-SalesforceDateTime [[-Datetime] <DateTime>] [<CommonParameters>]Description
Returns the value in UTC as 2026-11-18T11:00:00Z, ready to use in a SOQL WHERE clause. With no value it uses the current time. A local or unspecified time is converted to UTC first. It is a thin wrapper over ConvertTo-SalesforceSoqlDateTime.
Parameters
-DatetimeDateTime- The moment to format. Defaults to now. A local or unspecified kind is read as local time and converted to UTC.
Salesforce CLI
No direct Salesforce CLI command.
Examples
PS> Get-SalesforceDateTime (Get-Date).AddDays(-1)
PS> Yesterday, as a literal for a CreatedDate filter.Remarks
- To see the examples, type: "Get-Help Get-SalesforceDateTime -Examples"
- For more information, type: "Get-Help Get-SalesforceDateTime -Detailed"
- For technical information, type: "Get-Help Get-SalesforceDateTime -Full"
- For online help, type: "Get-Help Get-SalesforceDateTime -Online"
Related Links
Get-SalesforceLatestApiVersion
Synopsis
Returns the newest REST API version the org supports, such as v62.0.
Syntax
Get-SalesforceLatestApiVersion [[-TargetOrg] <String>] [<CommonParameters>]Description
Calls Get-SalesforceApiVersions and returns the highest version prefixed with v. Returns nothing if the org reports no versions.
Parameters
-TargetOrgString- Username or alias of the org to ask. If omitted, the Salesforce CLI uses the default target org (passed on to Get-SalesforceApiVersions).
Salesforce CLI
No direct Salesforce CLI command.
Examples
PS> Get-SalesforceLatestApiVersion -TargetOrg dev1For example v62.0.
Remarks
- To see the examples, type: "Get-Help Get-SalesforceLatestApiVersion -Examples"
- For more information, type: "Get-Help Get-SalesforceLatestApiVersion -Detailed"
- For technical information, type: "Get-Help Get-SalesforceLatestApiVersion -Full"
- For online help, type: "Get-Help Get-SalesforceLatestApiVersion -Online"
Related Links
Get-SalesforceLimits
Synopsis
Shows the org's limits and how much of each is left.
Syntax
Get-SalesforceLimits [[-TargetOrg] <String>] [[-Threshold] <Double>] [<CommonParameters>]Description
Runs sf org list limits and returns one object per limit with the name, max and remaining values the CLI reports, plus two calculated properties: Used is max minus remaining, in the limit's own unit (requests, MB, emails and so on). UsedPercent is Used as a percentage of max (0 to 100, a number rounded to two decimal places, not a string). When max is 0, missing or not a number (an unlimited, disabled or unknown limit), Used and UsedPercent are $null rather than a guess. Use -Threshold to return only the limits whose UsedPercent is at or above a value; limits with no UsedPercent are left out.
Parameters
-TargetOrgString- Username or alias of the target org. Not required if the `target-org` configuration variable is already set. Passed to sf as --target-org.
-ThresholdDouble- Optional. A percentage from 0 to 100. Returns only the limits whose UsedPercent is greater than or equal to this value (the boundary is inclusive). Limits with an unknown UsedPercent are not returned. Applied by psfdx; no CLI flag.
Salesforce CLI
sf org list limits
Examples
PS> Get-SalesforceLimits -TargetOrg prod -Threshold 80 | Sort-Object UsedPercent -Descending | Select-Object name, Used, max, UsedPercentLimits that are 80% or more used, highest first.
Remarks
- To see the examples, type: "Get-Help Get-SalesforceLimits -Examples"
- For more information, type: "Get-Help Get-SalesforceLimits -Detailed"
- For technical information, type: "Get-Help Get-SalesforceLimits -Full"
- For online help, type: "Get-Help Get-SalesforceLimits -Online"
Related Links
- https://developer.salesforce.com/docs/platform/salesforce-cli-reference/guide/cli_reference.html
- https://github.com/salesforcecli/plugin-limits
- https://github.com/tonygward/psfdx/blob/main/docs/cli-parity.md
- https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_commonparameters
Get-SalesforceUsers
Synopsis
Lists users of an org, newest login first.
Syntax
Get-SalesforceUsers [[-Username] <String>] [-ActiveOnly] [[-Limit] <Int32>] [[-TargetOrg] <String>] [<CommonParameters>]Description
Queries User (Id, Name, Username, Email, IsActive, LastLoginDate) through Select-SalesforceRecords, ordered by LastLoginDate descending. Values are escaped as SOQL literals.
Parameters
-UsernameString- Return only the user with this exact user name.
-ActiveOnlyswitch- Return only active users.
-LimitInt32- Maximum number of users to return. Default 200. Default: 200.
-TargetOrgString- Username or alias of the org to query. If omitted, the Salesforce CLI uses the default target org.
Salesforce CLI
No direct Salesforce CLI command.
Examples
PS> Get-SalesforceUsers -ActiveOnly -Limit 20 -TargetOrg prodThe 20 most recently active users.
Remarks
- To see the examples, type: "Get-Help Get-SalesforceUsers -Examples"
- For more information, type: "Get-Help Get-SalesforceUsers -Detailed"
- For technical information, type: "Get-Help Get-SalesforceUsers -Full"
- For online help, type: "Get-Help Get-SalesforceUsers -Online"
Related Links
Install-SalesforceCli
Synopsis
Installs the Salesforce CLI globally with npm.
Syntax
Install-SalesforceCli [-WhatIf] [-Confirm] [<CommonParameters>]Description
Runs npm install --global @salesforce/cli. This downloads and runs code from the npm registry. Node.js and npm must already be installed. Asks nothing by default, supports -WhatIf and -Confirm.
Commands that use sf check for Salesforce CLI v2 or newer when first needed. If sf is missing, set PSFDX_CLI_INSTALL to Prompt for an interactive confirmation, or Install to authorize unattended npm installation. The default is Never. Bootstrap can refresh the current session's PATH from npm and does not upgrade a CLI it finds.
Parameters
-WhatIfswitch-Confirmswitch
Salesforce CLI
No direct Salesforce CLI command.
Examples
PS> Install-SalesforceCli -WhatIfShow what would be installed.
Remarks
- To see the examples, type: "Get-Help Install-SalesforceCli -Examples"
- For more information, type: "Get-Help Install-SalesforceCli -Detailed"
- For technical information, type: "Get-Help Install-SalesforceCli -Full"
- For online help, type: "Get-Help Install-SalesforceCli -Online"
Related Links
Invoke-SalesforceApi
Synopsis
Calls a Salesforce REST API URL with an access token.
Syntax
Invoke-SalesforceApi [-Url] <String> [-AccessToken] <String> [[-Method] <String>] [<CommonParameters>]Description
Does not use the Salesforce CLI. It sends the request with Invoke-RestMethod and an Authorization: Bearer header, and returns the parsed response. The URL must be absolute and https, so the token is never sent over plain http. You choose the host; the cmdlet does not check that it is a Salesforce host.
Parameters
-UrlString, required- Absolute https:// URL of the REST resource. Required.
-AccessTokenString, required- Access token to send as the bearer token, for example from Connect-SalesforceApi. Required.
-MethodString- HTTP method: GET (default), POST, PATCH or DELETE. Default: "GET". Valid values: GET, POST, PATCH, DELETE.
Salesforce CLI
No direct Salesforce CLI command.
Examples
PS> Invoke-SalesforceApi -Url https://example.my.salesforce.com/services/data -AccessToken $tokenList the API versions of an org.
Remarks
- To see the examples, type: "Get-Help Invoke-SalesforceApi -Examples"
- For more information, type: "Get-Help Invoke-SalesforceApi -Detailed"
- For technical information, type: "Get-Help Invoke-SalesforceApi -Full"
- For online help, type: "Get-Help Invoke-SalesforceApi -Online"
Related Links
Update-SalesforceCli
Synopsis
Updates the Salesforce CLI installed with npm.
Syntax
Update-SalesforceCli [-WhatIf] [-Confirm] [<CommonParameters>]Description
Runs npm update --global @salesforce/cli. It downloads and runs code from the npm registry. Supports -WhatIf and -Confirm.
Parameters
-WhatIfswitch-Confirmswitch
Salesforce CLI
No direct Salesforce CLI command.
Examples
PS> Update-SalesforceCli -WhatIfShow what would be updated.
Remarks
- To see the examples, type: "Get-Help Update-SalesforceCli -Examples"
- For more information, type: "Get-Help Update-SalesforceCli -Detailed"
- For technical information, type: "Get-Help Update-SalesforceCli -Full"
- For online help, type: "Get-Help Update-SalesforceCli -Online"
Related Links
psfdx-logs
Convert-SalesforceDebugLog
Synopsis
Converts the text of a debug log into one object per line (in development).
Syntax
Convert-SalesforceDebugLog [-Log] <String> [<CommonParameters>]Description
Does not use the Salesforce CLI. Pipe in the text of a log, for example from Get-SalesforceDebugLogs -Raw; the first (header) line is skipped and each remaining line is split on | into DateTime, LogType and, when present, SubType and Detail. It writes a warning that it is still in development, so the properties may change.
Parameters
-LogString, required- The log text to convert. Accepts pipeline input. Required.
Salesforce CLI
No direct Salesforce CLI command.
Examples
PS> Get-SalesforceDebugLogs -Last 1 -Raw -TargetOrg dev1 | Convert-SalesforceDebugLog | Select-Object -First 20The first twenty log lines as objects.
Remarks
- To see the examples, type: "Get-Help Convert-SalesforceDebugLog -Examples"
- For more information, type: "Get-Help Convert-SalesforceDebugLog -Detailed"
- For technical information, type: "Get-Help Convert-SalesforceDebugLog -Full"
- For online help, type: "Get-Help Convert-SalesforceDebugLog -Online"
Related Links
Export-SalesforceDebugLogs
Synopsis
Saves the most recent debug logs to files.
Syntax
Export-SalesforceDebugLogs [[-Limit] <Int32>] [[-OutputFolder] <String>] [[-TargetOrg] <String>] [<CommonParameters>]Description
Lists the logs with Select-SalesforceDebugLogs, keeps the first -Limit of them and writes each one with Get-SalesforceDebugLogs to <log id>.log in the output folder, with a progress bar. Existing files with the same name are overwritten.
Parameters
-LimitInt32- How many logs to save, taken from the start of the list the CLI returns. Default 50. Default: 50.
-OutputFolderString- Folder to write the .log files to. It must exist. Defaults to the current folder.
-TargetOrgString- Username or alias of the org to read the logs from. If omitted, the Salesforce CLI uses the default target org.
Salesforce CLI
No direct Salesforce CLI command.
Examples
PS> Export-SalesforceDebugLogs -Limit 5 -OutputFolder .\logs -TargetOrg dev1Save the five newest logs.
Remarks
- To see the examples, type: "Get-Help Export-SalesforceDebugLogs -Examples"
- For more information, type: "Get-Help Export-SalesforceDebugLogs -Detailed"
- For technical information, type: "Get-Help Export-SalesforceDebugLogs -Full"
- For online help, type: "Get-Help Export-SalesforceDebugLogs -Online"
Related Links
Export-SalesforceEventFile
Synopsis
Downloads one Event Monitoring log file and saves it as a CSV.
Syntax
Export-SalesforceEventFile [-Id] <String> [[-OutputFolder] <String>] [[-TargetOrg] <String>] [<CommonParameters>]Description
Gets the file with Get-SalesforceEventFile and writes it to <Id>.csv in the output folder. The ID must be a 15 or 18 character Salesforce ID, so it cannot point outside the folder.
Parameters
-IdString, required- ID of the EventLogFile record. Required.
-OutputFolderString- Folder to write the CSV to. It must exist. Defaults to the current folder.
-TargetOrgString- Username or alias of the org. If omitted, the Salesforce CLI uses the default target org.
Salesforce CLI
No direct Salesforce CLI command.
Examples
PS> Export-SalesforceEventFile -Id 0AT000000000001AAA -OutputFolder .\events -TargetOrg prodSave one event log file.
Remarks
- To see the examples, type: "Get-Help Export-SalesforceEventFile -Examples"
- For more information, type: "Get-Help Export-SalesforceEventFile -Detailed"
- For technical information, type: "Get-Help Export-SalesforceEventFile -Full"
- For online help, type: "Get-Help Export-SalesforceEventFile -Online"
Related Links
Get-SalesforceLoginFailures
Synopsis
Lists login attempts that did not succeed.
Syntax
Get-SalesforceLoginFailures [[-After] <DateTime>] [[-Before] <DateTime>] [[-Limit] <Int32>] [[-Username] <String>] [[-TargetOrg] <String>] [<CommonParameters>]Description
Calls Get-SalesforceLoginHistory with the same filters and keeps the rows whose Status is not Success. Returns an empty array when there are none.
Parameters
-AfterDateTime- Only logins at or after this time.
-BeforeDateTime- Only logins at or before this time.
-LimitInt32- Maximum number of login history rows to read before filtering.
-UsernameString- Only this user name.
-TargetOrgString- Username or alias of the org. If omitted, the Salesforce CLI uses the default target org.
Salesforce CLI
No direct Salesforce CLI command.
Examples
PS> Get-SalesforceLoginFailures -After (Get-Date).AddDays(-1) -TargetOrg prodFailed logins in the last day.
Remarks
- To see the examples, type: "Get-Help Get-SalesforceLoginFailures -Examples"
- For more information, type: "Get-Help Get-SalesforceLoginFailures -Detailed"
- For technical information, type: "Get-Help Get-SalesforceLoginFailures -Full"
- For online help, type: "Get-Help Get-SalesforceLoginFailures -Online"
Related Links
Out-Notepad
Synopsis
Shows text in Notepad (Windows only).
Syntax
Out-Notepad [-Content] <String> [<CommonParameters>]Description
Does not use the Salesforce CLI. Pipe text in; it is written to a new temporary file that Notepad opens. The file is not deleted afterwards, so remove it if the text is sensitive. On other systems it does nothing.
Parameters
-ContentString, required- The text to show. Accepts pipeline input. Required.
Salesforce CLI
No direct Salesforce CLI command.
Examples
PS> Get-SalesforceDebugLogs -Last 1 -Raw -TargetOrg dev1 | Out-NotepadRead the newest log in Notepad.
Remarks
- To see the examples, type: "Get-Help Out-Notepad -Examples"
- For more information, type: "Get-Help Out-Notepad -Detailed"
- For technical information, type: "Get-Help Out-Notepad -Full"
- For online help, type: "Get-Help Out-Notepad -Online"
Related Links
psfdx-development
Debug-SalesforceJest
Synopsis
Runs the LWC Jest tests of the current project in debug mode.
Syntax
Debug-SalesforceJest [<CommonParameters>]Description
Runs npm run test:unit:debug in the current folder, so the project's package.json must define that script (the sfdx project template does). Output is returned as text.
Salesforce CLI
No direct Salesforce CLI command.
Examples
PS> Debug-SalesforceJestStart the Jest tests with the Node debugger.
Remarks
- To see the examples, type: "Get-Help Debug-SalesforceJest -Examples"
- For more information, type: "Get-Help Debug-SalesforceJest -Detailed"
- For technical information, type: "Get-Help Debug-SalesforceJest -Full"
- For online help, type: "Get-Help Debug-SalesforceJest -Online"
Related Links
Get-SalesforceApexClass
Synopsis
Gets an Apex class, including its source, from an org.
Syntax
Get-SalesforceApexClass [-Name] <String> [[-TargetOrg] <String>] [<CommonParameters>]Description
Queries ApexClass (Id, Name, Body) through the Tooling API with Select-SalesforceRecords. The name is matched exactly and escaped as a SOQL literal; at most one class is returned.
Parameters
-NameString, required- Exact name of the Apex class. Required.
-TargetOrgString- Username or alias of the org to query. If omitted, the Salesforce CLI uses the default target org.
Salesforce CLI
No direct Salesforce CLI command.
Examples
PS> (Get-SalesforceApexClass -Name MyService -TargetOrg dev1).BodyThe source code of MyService.
Remarks
- To see the examples, type: "Get-Help Get-SalesforceApexClass -Examples"
- For more information, type: "Get-Help Get-SalesforceApexClass -Detailed"
- For technical information, type: "Get-Help Get-SalesforceApexClass -Full"
- For online help, type: "Get-Help Get-SalesforceApexClass -Online"
Related Links
Get-SalesforceCodeCoverage
Synopsis
Shows Apex code coverage recorded in an org: per test method, or combined per class and trigger with -Aggregate.
Syntax
Get-SalesforceCodeCoverage [[-ApexClassOrTrigger] <String>] [[-TargetOrg] <String>] [-Aggregate] [[-Threshold] <Double>] [-IncludeMissing] [<CommonParameters>]Description
Without -Aggregate (the default, unchanged from earlier versions) it queries the Tooling API object ApexCodeCoverage and returns one object per class or trigger and test method: ApexClassOrTrigger, ApexTestClass, TestMethodName, CodeCoverage (a percentage string), CodeCoverageOK (true at 75 percent or more), NumLinesCovered and NumLinesUncovered. These are the lines one test method covered, so averaging them does not give a class's coverage.
With -Aggregate it queries ApexCodeCoverageAggregate, the org's combined coverage from every test run, and joins it to ApexClass and ApexTrigger. It returns one object per class or trigger with Name, Id, Type (ApexClass or ApexTrigger), NamespacePrefix, NumLinesCovered, NumLinesUncovered, NumLines, CoveragePercent and Status. CoveragePercent is NumLinesCovered divided by NumLines, as a number from 0 to 100 rounded to two decimal places; it is never an average of test percentages. Status is Covered; NoExecutableLines when NumLines is 0 (CoveragePercent is then $null, not 0 or 100); or NoCoverageData when there is no aggregate row because no test has run the class or trigger, or it is a test class. NoCoverageData rows are returned only with -IncludeMissing, and their counts and CoveragePercent are $null.
-Threshold (with -Aggregate) returns only classes and triggers below that percentage: CoveragePercent strictly less than the value, so exactly 75 passes a threshold of 75. NoExecutableLines rows are never returned by -Threshold. NoCoverageData rows are returned by -Threshold when -IncludeMissing is given, because Salesforce counts them as uncovered.
-ApexClassOrTrigger filters the result in PowerShell after the query, ignoring case: by class, trigger or test class name per test, or by class or trigger name with -Aggregate.
Parameters
-ApexClassOrTriggerString- Optional. Keep only rows for this class or trigger (or, without -Aggregate, this test class). The filter runs in PowerShell, after the query.
-TargetOrgString- Username or alias of the org to query. If omitted, the Salesforce CLI uses the default target org.
-Aggregateswitch- Optional switch. Return the combined coverage of each class and trigger (ApexCodeCoverageAggregate) instead of per-test-method rows.
-ThresholdDouble- Optional, with -Aggregate only. A percentage from 0 to 100. Returns only classes and triggers whose CoveragePercent is below this value (strictly less than). See the description for rows with no executable lines or no coverage data.
-IncludeMissingswitch- Optional switch, with -Aggregate only. Also return classes and triggers that have no aggregate coverage row, with Status NoCoverageData. Test classes have no coverage row, so they appear too.
Salesforce CLI
No direct Salesforce CLI command.
Examples
PS> Get-SalesforceCodeCoverage -Aggregate -Threshold 75 -TargetOrg dev1 | Sort-Object CoveragePercent | Select-Object Name, Type, CoveragePercent, NumLinesUncoveredClasses and triggers below 75 percent coverage, lowest first.
Remarks
- To see the examples, type: "Get-Help Get-SalesforceCodeCoverage -Examples"
- For more information, type: "Get-Help Get-SalesforceCodeCoverage -Detailed"
- For technical information, type: "Get-Help Get-SalesforceCodeCoverage -Full"
- For online help, type: "Get-Help Get-SalesforceCodeCoverage -Online"
Related Links
Install-SalesforceJest
Synopsis
Installs the LWC Jest test runner into the current project.
Syntax
Install-SalesforceJest [-WhatIf] [-Confirm] [<CommonParameters>]Description
Runs yarn add -D @salesforce/sfdx-lwc-jest when yarn is on the PATH, otherwise npm install -D @salesforce/sfdx-lwc-jest. This downloads and runs code from the package registry. Node.js is required.
Parameters
-WhatIfswitch-Confirmswitch
Salesforce CLI
No direct Salesforce CLI command.
Examples
PS> Install-SalesforceJestAdd the Jest runner as a dev dependency.
Remarks
- To see the examples, type: "Get-Help Install-SalesforceJest -Examples"
- For more information, type: "Get-Help Install-SalesforceJest -Detailed"
- For technical information, type: "Get-Help Install-SalesforceJest -Full"
- For online help, type: "Get-Help Install-SalesforceJest -Online"
Related Links
New-SalesforceJestTest
Synopsis
Writes a starter Jest test for a Lightning web component.
Syntax
New-SalesforceJestTest [-LwcName] <String> [[-ProjectPath] <String>] [-Force] [<CommonParameters>]Description
Does not use the Salesforce CLI (the old sf force lightning lwc test create command was removed). It writes <name>.test.js into the component's __tests__ folder, with a test that renders the component. It refuses to overwrite an existing test unless you pass -Force.
Parameters
-LwcNameString, required- Name of the Lightning web component (letters, digits and underscores, starting with a letter). Its folder must exist under force-app/main/default/lwc. Required.
-ProjectPathString- Root folder of the Salesforce DX project. It must exist. Default: ..
-Forceswitch- Overwrite the test file if it already exists.
Salesforce CLI
No direct Salesforce CLI command.
Examples
PS> New-SalesforceJestTest -LwcName accountCard -ProjectPath .Create force-app/main/default/lwc/accountCard/__tests__/accountCard.test.js.
Remarks
- To see the examples, type: "Get-Help New-SalesforceJestTest -Examples"
- For more information, type: "Get-Help New-SalesforceJestTest -Detailed"
- For technical information, type: "Get-Help New-SalesforceJestTest -Full"
- For online help, type: "Get-Help New-SalesforceJestTest -Online"
Related Links
Test-SalesforceJest
Synopsis
Runs the LWC Jest tests of the current project once.
Syntax
Test-SalesforceJest [<CommonParameters>]Description
Runs npm run test:unit in the current folder, so the project's package.json must define that script.
Salesforce CLI
No direct Salesforce CLI command.
Examples
PS> Test-SalesforceJestRun every Jest test.
Remarks
- To see the examples, type: "Get-Help Test-SalesforceJest -Examples"
- For more information, type: "Get-Help Test-SalesforceJest -Detailed"
- For technical information, type: "Get-Help Test-SalesforceJest -Full"
- For online help, type: "Get-Help Test-SalesforceJest -Online"
Related Links
Wait-SalesforceApexTest
Synopsis
Waits for an Apex test run to finish and returns its results.
Syntax
Wait-SalesforceApexTest [-TestRunId] <String> [[-TimeoutMinutes] <Int32>] [[-PollSeconds] <Int32>] [-CodeCoverage] [-CodeCoverageDetailed] [-Concise] [[-OutputDirectory] <String>] [[-TargetOrg] <String>] [<CommonParameters>]Description
Polls Get-SalesforceApexTestResult every -PollSeconds until the run is no longer queued or processing, then returns the same object. If -TimeoutMinutes pass first it throws PsfdxTestRunTimeout, whose TargetObject is the TestRunId, and the run carries on in the org. Failing tests and CLI errors surface exactly as for Get-SalesforceApexTestResult.
Parameters
-TestRunIdString, required- ID of the test run to wait for, as returned by Start-SalesforceApexTest or Test-SalesforceApex. It must start with 707. Required.
-TimeoutMinutesInt32- How long to wait, in minutes, before giving up with PsfdxTestRunTimeout. The run carries on in the org. Default 10. Default: 10. Range: 1 to 1440.
-PollSecondsInt32- Seconds to wait between checks of the run's status. Default 10. Default: 10. Range: 1 to 600.
-CodeCoverageswitch- Include code coverage in the result. Passed on to Get-SalesforceApexTestResult as --code-coverage; the run must have been started with coverage.
-CodeCoverageDetailedswitch- Include line-by-line code coverage. Passed on to Get-SalesforceApexTestResult as --detailed-coverage.
-Conciseswitch- Show only failing tests in human-readable output. Passed on to Get-SalesforceApexTestResult as --concise.
-OutputDirectoryString- Folder to write the result files to. Passed on to Get-SalesforceApexTestResult as --output-dir.
-TargetOrgString- Username or alias of the org the run is in. If omitted, the Salesforce CLI uses the default target org.
Salesforce CLI
No direct Salesforce CLI command.
Examples
PS> $run = Start-SalesforceApexTest -TargetOrg myorg; Wait-SalesforceApexTest -TestRunId $run.TestRunId -TimeoutMinutes 30 -CodeCoverage -TargetOrg myorgRemarks
- To see the examples, type: "Get-Help Wait-SalesforceApexTest -Examples"
- For more information, type: "Get-Help Wait-SalesforceApexTest -Detailed"
- For technical information, type: "Get-Help Wait-SalesforceApexTest -Full"
- For online help, type: "Get-Help Wait-SalesforceApexTest -Online"
Related Links
Watch-SalesforceApex
Synopsis
Runs Apex tests and deploys automatically when you save an Apex file.
Syntax
Watch-SalesforceApex [[-ProjectFolder] <String>] [[-CooldownMilliseconds] <Int32>] [-IgnoreErrors] [<CommonParameters>]Description
Watches the project folder with a file system watcher. On each change to an Apex class or trigger file it deploys that one component and, when it finds test classes that reference it in the project, runs them as part of the deployment. It keeps running until you press Ctrl+C. The deployment goes to the default target org; there is no -TargetOrg.
Parameters
-ProjectFolderString- Folder of the Salesforce DX project to watch. Defaults to the current folder. It must exist.
-CooldownMillisecondsInt32- Ignore repeat events for the same file within this many milliseconds. Default 300. Default: 300.
-IgnoreErrorsswitch- Keep watching after a deploy or test fails instead of stopping.
Salesforce CLI
No direct Salesforce CLI command.
Examples
PS> Watch-SalesforceApex -ProjectFolder .Deploy and test on every save.
Remarks
- To see the examples, type: "Get-Help Watch-SalesforceApex -Examples"
- For more information, type: "Get-Help Watch-SalesforceApex -Detailed"
- For technical information, type: "Get-Help Watch-SalesforceApex -Full"
- For online help, type: "Get-Help Watch-SalesforceApex -Online"
Related Links
Watch-SalesforceJest
Synopsis
Runs the LWC Jest tests and re-runs them when files change.
Syntax
Watch-SalesforceJest [<CommonParameters>]Description
Runs npm run test:unit:watch in the current folder, so the project's package.json must define that script. It keeps running until you stop it.
Salesforce CLI
No direct Salesforce CLI command.
Examples
PS> Watch-SalesforceJestWatch mode for Jest.
Remarks
- To see the examples, type: "Get-Help Watch-SalesforceJest -Examples"
- For more information, type: "Get-Help Watch-SalesforceJest -Detailed"
- For technical information, type: "Get-Help Watch-SalesforceJest -Full"
- For online help, type: "Get-Help Watch-SalesforceJest -Online"
Related Links
psfdx-org
Remove-SalesforceScratchOrgs
Synopsis
Deletes every scratch org this computer knows about.
Syntax
Remove-SalesforceScratchOrgs [-WhatIf] [-Confirm] [<CommonParameters>]Description
Lists scratch orgs with Get-SalesforceScratchOrgs and deletes each one with Remove-SalesforceScratchOrg -NoPrompt. One confirmation names all of them. This cannot be undone. Supports -WhatIf.
Parameters
-WhatIfswitch-Confirmswitch
Salesforce CLI
No direct Salesforce CLI command.
Examples
PS> Remove-SalesforceScratchOrgs -WhatIfList the orgs that would be deleted.
Remarks
- To see the examples, type: "Get-Help Remove-SalesforceScratchOrgs -Examples"
- For more information, type: "Get-Help Remove-SalesforceScratchOrgs -Detailed"
- For technical information, type: "Get-Help Remove-SalesforceScratchOrgs -Full"
- For online help, type: "Get-Help Remove-SalesforceScratchOrgs -Online"
Related Links
psfdx-metadata
Build-SalesforceQuery
Synopsis
Builds a SELECT statement that lists every field of an object.
Syntax
Build-SalesforceQuery [-ObjectName] <String> [[-TargetOrg] <String>] [-UseToolingApi] [-ExcludeAuditFields] [-ExcludeNameFields] [-ExcludeContextFields] [<CommonParameters>]Description
Reads the object's fields with Describe-SalesforceFields and returns the query text, for example SELECT Id,Name FROM Account. Use the switches to leave out groups of fields. Returns an empty string when the object has no fields. Field and object names are checked so only valid API names end up in the query.
Parameters
-ObjectNameString, required- API name of the object. Required.
-TargetOrgString- Username or alias of the org to describe. If omitted, the Salesforce CLI uses the default target org.
-UseToolingApiswitch- Describe a Tooling API object instead of a standard or custom one.
-ExcludeAuditFieldsswitch- Leave out CreatedById, CreatedDate, LastModifiedById, LastModifiedDate, SystemModstamp and IsDeleted.
-ExcludeNameFieldsswitch- Leave out Name, FirstName, LastName and Subject.
-ExcludeContextFieldsswitch- Leave out OwnerId, RecordTypeId, CurrencyIsoCode and Division.
Salesforce CLI
No direct Salesforce CLI command.
Examples
PS> Build-SalesforceQuery -ObjectName Account -ExcludeAuditFields -TargetOrg dev1
PS> A query for the fields of Account without the audit fields.Remarks
- To see the examples, type: "Get-Help Build-SalesforceQuery -Examples"
- For more information, type: "Get-Help Build-SalesforceQuery -Detailed"
- For technical information, type: "Get-Help Build-SalesforceQuery -Full"
- For online help, type: "Get-Help Build-SalesforceQuery -Online"
Related Links
Clear-SalesforceMetadataTypeCache
Synopsis
Forgets the metadata types psfdx cached for -Type completion.
Syntax
Clear-SalesforceMetadataTypeCache [<CommonParameters>]Description
Does not use the Salesforce CLI. psfdx caches each org's list of metadata types for the session so -Type can be completed and checked (an unknown type gives a warning); this removes the cache for every org so the next use asks the org again.
Salesforce CLI
No direct Salesforce CLI command.
Examples
PS> Clear-SalesforceMetadataTypeCacheForce a fresh list of metadata types.
Remarks
- To see the examples, type: "Get-Help Clear-SalesforceMetadataTypeCache -Examples"
- For more information, type: "Get-Help Clear-SalesforceMetadataTypeCache -Detailed"
- For technical information, type: "Get-Help Clear-SalesforceMetadataTypeCache -Full"
- For online help, type: "Get-Help Clear-SalesforceMetadataTypeCache -Online"
Related Links
Compare-SalesforceFields
Synopsis
Compares the fields of objects in two orgs: fields missing from either org, and changed type, length, requiredness, lookups, formulas and picklist values.
Syntax
Compare-SalesforceFields [-SourceOrg] <String> [-TargetOrg] <String> [-ObjectName] <String[]> [-CustomOnly] [<CommonParameters>]Description
Reads the field inventory of each object in the source and the target org with Get-SalesforceFieldInventory and returns one object per difference, with ObjectName, FieldName, NamespacePrefix, Difference, Property, SourceValue, TargetValue, SourceOrg and TargetOrg. Nothing is deployed or changed in either org. Difference is MissingInTarget or MissingInSource for a field that exists in one org only (Property is Type and the values are its type), Changed for a property that differs (one row per property), or ObjectMissingInTarget, ObjectMissingInSource or ObjectMissingInBoth when the object itself is absent. The properties compared are Type, Length, Precision, Scale, Nillable (whether the field can be empty), Custom, ReferenceTo, RelationshipName, Calculated, Formula, Unique, ExternalId and PicklistValues (the active values). Lists are compared as sorted sets, so only a different set of values is a difference, not a different order. Field names are matched ignoring case, as Salesforce does. An object that does not exist in an org is reported as a difference. Any other failure, such as a missing authorization or no access to the object, throws with the org's name, so an access problem is never reported as an absent object. Identical orgs return nothing. The rows are sorted by object, field and property, so two runs give the same output.
Parameters
-SourceOrgString, required- Username or alias of the org to compare from. Required.
-TargetOrgString, required- Username or alias of the org to compare with. Required.
-ObjectNameString[], required- API names of the objects to compare. Required.
-CustomOnlyswitch- Optional switch. Compare custom fields only.
Salesforce CLI
No direct Salesforce CLI command.
Examples
PS> Compare-SalesforceFields -SourceOrg uat -TargetOrg prod -ObjectName Account, Opportunity | Format-Table ObjectName, FieldName, Difference, Property, SourceValue, TargetValueThe field differences between UAT and production on two objects.
Remarks
- To see the examples, type: "Get-Help Compare-SalesforceFields -Examples"
- For more information, type: "Get-Help Compare-SalesforceFields -Detailed"
- For technical information, type: "Get-Help Compare-SalesforceFields -Full"
- For online help, type: "Get-Help Compare-SalesforceFields -Online"
Related Links
Compare-SalesforceMetadata
Synopsis
Compares the metadata components of chosen types in two orgs: components missing from either org and, with -IncludeContent, components whose content differs.
Syntax
Compare-SalesforceMetadata [-SourceOrg] <String> [-TargetOrg] <String> [-MetadataType] <String[]> [-IncludeContent] [<CommonParameters>]Description
Lists the components of each metadata type in the source and the target org with Get-SalesforceMetadataComponents and returns one object per difference, with MetadataType, FullName, NamespacePrefix, Difference, Detail, SourceValue, TargetValue, SourceOrg and TargetOrg. Nothing is deployed or changed in either org. Difference is MissingInTarget or MissingInSource for a component that exists in one org only. With -IncludeContent each type is also retrieved from both orgs into temporary folders (Metadata API format) and the files of components in both orgs are compared after normalising line endings, trailing spaces and blank lines; a file that still differs is one ContentChanged row, with Detail set to its path and SourceValue and TargetValue set to the SHA-256 hash of each normalised file. FullName is then read from the file name. The temporary folders are deleted afterwards. A type that an org cannot list or retrieve (an unsupported type, or one that needs a folder, such as Report) is reported as Unsupported or RetrieveFailed, with the CLI message in Detail and the org it applies to in SourceValue or TargetValue, instead of being skipped silently. A missing authorization or other access failure throws with the org's name, so it is never reported as missing components. Identical orgs return nothing. Rows are sorted by type and name.
Parameters
-SourceOrgString, required- Username or alias of the org to compare from. Required. Passed to sf as --target-org.
-TargetOrgString, required- Username or alias of the org to compare with. Required. Passed to sf as --target-org.
-MetadataTypeString[], required- Metadata types to compare, for example ApexClass, Flow or CustomObject. Required. With -IncludeContent each is passed to sf as --metadata.
-IncludeContentswitch- Optional switch. Also retrieve the components and compare their content. Slower, and it downloads the metadata of these types from both orgs.
Salesforce CLI
sf project retrieve start
Examples
PS> Compare-SalesforceMetadata -SourceOrg uat -TargetOrg prod -MetadataType ApexClass, Flow | Format-Table MetadataType, FullName, DifferenceClasses and flows that exist in only one of the two orgs.
Remarks
- To see the examples, type: "Get-Help Compare-SalesforceMetadata -Examples"
- For more information, type: "Get-Help Compare-SalesforceMetadata -Detailed"
- For technical information, type: "Get-Help Compare-SalesforceMetadata -Full"
- For online help, type: "Get-Help Compare-SalesforceMetadata -Online"
Related Links
Compare-SalesforcePermissions
Synopsis
Compares the object and field permissions that named permission sets and profiles grant in two orgs.
Syntax
Compare-SalesforcePermissions [-SourceOrg] <String> [-TargetOrg] <String> [[-PermissionSet] <String[]>] [[-Profile] <String[]>] [[-ObjectName] <String[]>] [<CommonParameters>]Description
Reads the named permission sets and profiles and their ObjectPermissions and FieldPermissions in the source and the target org with SOQL, and returns one object per difference, with Scope (PermissionSet or Profile), Name, Kind (Container, Object or Field), ObjectName, FieldName, Permission, Difference, SourceValue, TargetValue, SourceOrg and TargetOrg. Nothing is deployed or changed in either org. Only the permission sets and profiles you name are compared: give -PermissionSet, -Profile or both. A permission set or profile that exists in one org only is reported once, with Kind Container and Difference MissingInTarget, MissingInSource or MissingInBoth, and its permissions are not compared. For one that exists in both, each object permission (Read, Create, Edit, Delete, ViewAllRecords, ModifyAllRecords) and field permission (Read, Edit) that differs is one row with Difference Changed and the two true or false values. An object or field with no permission record in an org has no access there, as in Salesforce, so it compares as false. This compares what the named permission sets and profiles grant. It is not a user's effective access, which also depends on their other permission sets and groups, muting permission sets, sharing and the user's licence. -ObjectName limits the comparison to some objects and their fields. A query that fails for any reason, such as a missing authorization, throws with the org's name. Identical orgs return nothing. The rows are sorted, so two runs give the same output.
Parameters
-SourceOrgString, required- Username or alias of the org to compare from. Required. Passed to sf as --target-org for the source queries.
-TargetOrgString, required- Username or alias of the org to compare with. Required. Passed to sf as --target-org for the target queries.
-PermissionSetString[]- API names of the permission sets to compare. Give this, -Profile or both.
-ProfileString[]- Names of the profiles to compare, for example 'System Administrator'. Give this, -PermissionSet or both.
-ObjectNameString[]- Optional. Compare only the permissions on these objects and their fields.
Salesforce CLI
sf data query
Examples
PS> Compare-SalesforcePermissions -SourceOrg uat -TargetOrg prod -PermissionSet Sales_Ops -ObjectName Opportunity | Format-Table Kind, ObjectName, FieldName, Permission, SourceValue, TargetValueHow the Sales_Ops permission set differs on Opportunity between UAT and production.
Remarks
- To see the examples, type: "Get-Help Compare-SalesforcePermissions -Examples"
- For more information, type: "Get-Help Compare-SalesforcePermissions -Detailed"
- For technical information, type: "Get-Help Compare-SalesforcePermissions -Full"
- For online help, type: "Get-Help Compare-SalesforcePermissions -Online"
Related Links
Describe-SalesforceFields
Synopsis
Lists the fields of an object.
Syntax
Describe-SalesforceFields [-ObjectName] <String> [[-TargetOrg] <String>] [-UseToolingApi] [<CommonParameters>]Description
Describes the object with Describe-SalesforceObject and returns the complete describe of each field, sorted by name: every property the API returns, including custom, nillable, referenceTo, relationshipName, calculated, calculatedFormula, length, precision, scale, unique, externalId, picklistValues, createable and updateable. False, null and empty values are kept as the API sent them. A namespaced field keeps its prefix in name (ns__Field__c). The default table still shows name, label, type and byteLength; use Select-Object or Format-List * to see the rest. Earlier versions returned only those four properties, so Export-Csv now writes every property: select the columns you want first.
Parameters
-ObjectNameString, required- API name of the object. Required.
-TargetOrgString- Username or alias of the org. If omitted, the Salesforce CLI uses the default target org.
-UseToolingApiswitch- Describe a Tooling API object instead of a standard or custom one.
Salesforce CLI
No direct Salesforce CLI command.
Examples
PS> Describe-SalesforceFields -ObjectName Account -TargetOrg dev1The fields of Account.
Remarks
- To see the examples, type: "Get-Help Describe-SalesforceFields -Examples"
- For more information, type: "Get-Help Describe-SalesforceFields -Detailed"
- For technical information, type: "Get-Help Describe-SalesforceFields -Full"
- For online help, type: "Get-Help Describe-SalesforceFields -Online"
Related Links
Get-SalesforceDeploySummary
Synopsis
Summarises a deployment or validation in one flat object: status, counts, component failures, test failures and coverage gaps.
Syntax
Get-SalesforceDeploySummary [-JobId <String>] [-UseMostRecent] [-Wait <Int32>] [-TargetOrg <String>] [<CommonParameters>]
Get-SalesforceDeploySummary -InputObject <PSObject> [<CommonParameters>]Description
Runs sf project deploy report for a job ID, or the most recent job with -UseMostRecent, and returns one flat object: JobId, Status, Success, IsComplete, CheckOnly, TestLevel, RunTestsEnabled, StartDate, CompletedDate, ComponentsDeployed, ComponentErrors, ComponentsTotal, TestsCompleted, TestErrors, TestsTotal, ComponentFailures, TestFailures, CoverageWarnings, LowCoverage, ErrorMessage and Details. A failed deployment is summarised, not thrown: the CLI reports it with a non-zero status, and this cmdlet reads the deployment result from that report. It throws only when the report has no deployment result, for example when the job ID is unknown or the org is not authorized. ComponentFailures has ComponentType, FullName, FileName, LineNumber, ColumnNumber, ProblemType and Problem for each failed component. TestFailures has ClassName, MethodName, Message and StackTrace for each failed test. CoverageWarnings has Name and Message for each coverage warning the org reported. LowCoverage lists the classes and triggers in the test result's coverage below 75 percent, with Name, Type, LinesCovered, LinesNotCovered and CoveragePercent. IsComplete is false while the job is still queued or running; the counts are then the ones reported so far. TestLevel is filled only when the report includes one; the deployment result usually does not, so it is often $null (RunTestsEnabled says whether tests ran). Details is the CLI's complete deployment result, unchanged. You can also pipe in a result you already have, such as the output of Get-SalesforceDeployStatus; then no command runs.
Parameters
-JobIdString- ID of the deployment or validation job (0Af...). Give this or -UseMostRecent. Passed to sf as --job-id.
-UseMostRecentswitch- Optional switch. Summarise the most recent deployment instead of a given job. Adds --use-most-recent.
-WaitInt32- Optional. Minutes for the CLI to wait for the job to finish before reporting. Passed to sf as --wait.
-TargetOrgString- Username or alias of the target org. Not required if the `target-org` configuration variable is already set. Passed to sf as --target-org.
-InputObjectPSObject, required- A deployment result you already have (from the pipeline). When given, no command runs. Not a CLI flag.
Salesforce CLI
sf project deploy report
Examples
PS> Get-SalesforceDeploySummary -JobId 0Af000000000001AAA -TargetOrg prodThe status, failures and coverage gaps of one deployment.
Remarks
- To see the examples, type: "Get-Help Get-SalesforceDeploySummary -Examples"
- For more information, type: "Get-Help Get-SalesforceDeploySummary -Detailed"
- For technical information, type: "Get-Help Get-SalesforceDeploySummary -Full"
- For online help, type: "Get-Help Get-SalesforceDeploySummary -Online"
Related Links
- https://developer.salesforce.com/docs/platform/salesforce-cli-reference/guide/cli_reference.html
- https://github.com/salesforcecli/plugin-deploy-retrieve
- https://github.com/tonygward/psfdx/blob/main/docs/cli-parity.md
- https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_commonparameters
Get-SalesforceFieldInventory
Synopsis
Lists the fields of one or more objects as a flat inventory: API name, type, custom, nillable, lookup target, formula and namespace.
Syntax
Get-SalesforceFieldInventory [-ObjectName] <String[]> [-CustomOnly] [[-TargetOrg] <String>] [<CommonParameters>]Description
Describes each object with Describe-SalesforceObject and returns one flat object per field, sorted by object and field name, with ObjectName, Name, Label, Type, Length, Precision, Scale, Custom, Nillable, ReferenceTo, RelationshipName, Calculated, Formula, NamespacePrefix, Unique, ExternalId, Createable, Updateable, DefaultedOnCreate and PicklistValues (the active values of a picklist, empty for other fields). Every value is copied from the field describe. A property the describe does not include is $null, never a guess. ReferenceTo is always an array (empty for a field that is not a lookup). NamespacePrefix is read from the API name: a name such as acme__Score__c has the prefix acme, because a field's own name cannot contain a double underscore; standard fields and local custom fields have none. -CustomOnly keeps only custom fields. Use Describe-SalesforceFields when you need every property of the describe.
Parameters
-ObjectNameString[], required- API names of the objects, for example Account or Invoice__c. Required. Each object is described once.
-CustomOnlyswitch- Optional switch. Return only custom fields (custom is true).
-TargetOrgString- Username or alias of the org. If omitted, the Salesforce CLI uses the default target org.
Salesforce CLI
No direct Salesforce CLI command.
Examples
PS> Get-SalesforceFieldInventory -ObjectName Account -CustomOnly -TargetOrg dev1 | Format-Table Name, Type, Nillable, ReferenceTo, CalculatedThe custom fields of Account.
Remarks
- To see the examples, type: "Get-Help Get-SalesforceFieldInventory -Examples"
- For more information, type: "Get-Help Get-SalesforceFieldInventory -Detailed"
- For technical information, type: "Get-Help Get-SalesforceFieldInventory -Full"
- For online help, type: "Get-Help Get-SalesforceFieldInventory -Online"
Related Links
Get-SalesforceFlows
Synopsis
Lists the flows in an org with their active version, API version and whether a newer draft exists.
Syntax
Get-SalesforceFlows [-ActiveOnly] [[-Name] <String>] [[-TargetOrg] <String>] [<CommonParameters>]Description
Queries the Tooling API objects FlowDefinition and Flow (the flow versions) and returns one object per flow definition: Name (the API name), Label, NamespacePrefix, ProcessType, IsActive, ActiveVersionNumber, ActiveVersionApiVersion, LatestVersionNumber, LatestVersionStatus, HasNewerDraft, DefinitionId, ActiveVersionId, LatestVersionId and VersionDataComplete. IsActive is true when the definition has an active version. An inactive flow has no ActiveVersionNumber or ActiveVersionApiVersion ($null, not 0). LatestVersionStatus is the status of the newest version as Salesforce reports it (Active, Draft, InvalidDraft or Obsolete). HasNewerDraft is true when the newest version is a draft that is not the active one. ProcessType (Flow, AutoLaunchedFlow, Workflow for record-triggered and process flows, and so on) comes from the active version, or from the latest version of an inactive flow. VersionDataComplete is false when a version the definition points to was not returned by the query; the values that would come from it are then $null. -ActiveOnly keeps only active flows. -Name keeps one flow by API name (ignoring case).
Parameters
-ActiveOnlyswitch- Optional switch. Return only flows that have an active version.
-NameString- Optional. The API name (DeveloperName) of one flow. The filter runs in PowerShell, after the query, and ignores case.
-TargetOrgString- Username or alias of the org. If omitted, the Salesforce CLI uses the default target org. Passed to sf as --target-org.
Salesforce CLI
sf data query
Examples
PS> Get-SalesforceFlows -ActiveOnly -TargetOrg dev1 | Format-Table Name, ProcessType, ActiveVersionNumber, ActiveVersionApiVersionThe active flows, their active version and its API version.
Remarks
- To see the examples, type: "Get-Help Get-SalesforceFlows -Examples"
- For more information, type: "Get-Help Get-SalesforceFlows -Detailed"
- For technical information, type: "Get-Help Get-SalesforceFlows -Full"
- For online help, type: "Get-Help Get-SalesforceFlows -Online"
Related Links
Retrieve-SalesforceField
Synopsis
Retrieves one custom field into the project.
Syntax
Retrieve-SalesforceField [-ObjectName] <String> [-FieldName] <String> [[-TargetOrg] <String>] [<CommonParameters>]Description
A shortcut for Retrieve-SalesforceComponent -Type CustomField with the object as the name and the field as the child name.
Parameters
-ObjectNameString, required- API name of the object that holds the field. Required.
-FieldNameString, required- API name of the field, for example Rating__c. Required.
-TargetOrgString- Username or alias of the org. If omitted, the Salesforce CLI uses the default target org.
Salesforce CLI
No direct Salesforce CLI command.
Examples
PS> Retrieve-SalesforceField -ObjectName Account -FieldName Rating__c -TargetOrg dev1Retrieve Account.Rating__c.
Remarks
- To see the examples, type: "Get-Help Retrieve-SalesforceField -Examples"
- For more information, type: "Get-Help Retrieve-SalesforceField -Detailed"
- For technical information, type: "Get-Help Retrieve-SalesforceField -Full"
- For online help, type: "Get-Help Retrieve-SalesforceField -Online"
Related Links
Retrieve-SalesforceValidationRule
Synopsis
Retrieves one validation rule into the project.
Syntax
Retrieve-SalesforceValidationRule [-ObjectName] <String> [-RuleName] <String> [[-TargetOrg] <String>] [<CommonParameters>]Description
A shortcut for Retrieve-SalesforceComponent -Type ValidationRule with the object and rule name combined.
Parameters
-ObjectNameString, required- API name of the object that holds the rule. Required.
-RuleNameString, required- Name of the validation rule. Required.
-TargetOrgString- Username or alias of the org. If omitted, the Salesforce CLI uses the default target org.
Salesforce CLI
No direct Salesforce CLI command.
Examples
PS> Retrieve-SalesforceValidationRule -ObjectName Account -RuleName Require_Name -TargetOrg dev1Retrieve one rule.
Remarks
- To see the examples, type: "Get-Help Retrieve-SalesforceValidationRule -Examples"
- For more information, type: "Get-Help Retrieve-SalesforceValidationRule -Detailed"
- For technical information, type: "Get-Help Retrieve-SalesforceValidationRule -Full"
- For online help, type: "Get-Help Retrieve-SalesforceValidationRule -Online"
Related Links
psfdx-data
Get-SalesforceRecordType
Synopsis
Lists record types, optionally for one object.
Syntax
Get-SalesforceRecordType [-ObjectType] <String> [[-TargetOrg] <String>] [<CommonParameters>]Description
Queries the RecordType object (Id, SobjectType, Name, DeveloperName, IsActive) through Select-SalesforceRecords. The object name is escaped as a SOQL literal.
Parameters
-ObjectTypeString, required- API name of the object whose record types you want, for example Account. Without it, record types of every object are returned. Required.
-TargetOrgString- Username or alias of the org to query. If omitted, the Salesforce CLI uses the default target org.
Salesforce CLI
No direct Salesforce CLI command.
Examples
PS> Get-SalesforceRecordType -ObjectType Account -TargetOrg dev1Record types of Account.
Remarks
- To see the examples, type: "Get-Help Get-SalesforceRecordType -Examples"
- For more information, type: "Get-Help Get-SalesforceRecordType -Detailed"
- For technical information, type: "Get-Help Get-SalesforceRecordType -Full"
- For online help, type: "Get-Help Get-SalesforceRecordType -Online"
Related Links
psfdx-packages
Get-SalesforcePackage
Synopsis
Finds one package by name.
Syntax
Get-SalesforcePackage [-Name] <String> [[-TargetDevHub] <String>] [-ExtendedPackageDetails] [<CommonParameters>]Description
Lists the packages with Get-SalesforcePackages and returns the one whose name matches exactly, or nothing.
Parameters
-NameString, required- Exact name of the package. Required.
-TargetDevHubString- Username or alias of the Dev Hub org that owns the package. Passed to Get-SalesforcePackages, which passes it to sf as --target-dev-hub.
-ExtendedPackageDetailsswitch- Include extended package details. Passed to Get-SalesforcePackages, which passes it to sf as --verbose.
Salesforce CLI
No direct Salesforce CLI command.
Examples
PS> Get-SalesforcePackage -Name MyPackage -TargetDevHub devhubThe package record.
Remarks
- To see the examples, type: "Get-Help Get-SalesforcePackage -Examples"
- For more information, type: "Get-Help Get-SalesforcePackage -Detailed"
- For technical information, type: "Get-Help Get-SalesforcePackage -Full"
- For online help, type: "Get-Help Get-SalesforcePackage -Online"
