MODULE REFERENCE / psfdx-org
psfdx-org
Sandboxes and scratch orgs
Create, inspect, refresh, resume and delete Salesforce sandboxes and scratch orgs.
Part of the psfdx package, which installs every module: see the installation and update instructions. This module was psfdx-sandbox; its commands are unchanged, and the scratch org commands moved here from psfdx-development.
PS> Get-Command -Module psfdx-orgCommands
Download Markdown · Source history on GitHub
Sandboxes
Copy-SalesforceSandbox
Synopsis
Creates a sandbox as a copy of another sandbox.
Syntax
Copy-SalesforceSandbox -SourceSandboxName <String> -CloneSandboxName <String> [-LicenseType <String>] [-Alias <String>] [-WaitMinutes <Int32>] [-NoPrompt] [-Async] [-PollIntervalSeconds <Int32>] [-SetDefault] [-TargetOrg <String>] [<CommonParameters>]
Copy-SalesforceSandbox -SourceId <String> -CloneSandboxName <String> [-LicenseType <String>] [-Alias <String>] [-WaitMinutes <Int32>] [-NoPrompt] [-Async] [-PollIntervalSeconds <Int32>] [-SetDefault] [-TargetOrg <String>] [<CommonParameters>]Description
Runs sf org create sandbox with --source-sandbox-name, which clones an existing sandbox. The CLI waits only when you give -WaitMinutes.
Parameters
-SourceSandboxNameString, required- Name of the sandbox org to clone. Passed to sf as --source-sandbox-name. Required unless you give -SourceId.
-SourceIdString, required- ID of the sandbox to clone, instead of its name. Passed to sf as --source-id. Use it instead of -SourceSandboxName.
-CloneSandboxNameString, required- Name of the sandbox org. Passed to sf as --name. Required.
-LicenseTypeString- Type of sandbox license. Passed to sf as --license-type.
-AliasString- Alias for the sandbox org. Passed to sf as --alias.
-WaitMinutesInt32- Number of minutes to wait for the sandbox org to be ready. Passed to sf as --wait.
-NoPromptswitch- Don't prompt for confirmation about the sandbox configuration. Adds --no-prompt.
-Asyncswitch- Request the clone and return at once, without waiting for it to be ready. Finish with Resume-SalesforceSandbox. Adds --async.
-PollIntervalSecondsInt32- Number of seconds to wait between checks while waiting for the sandbox. Passed to sf as --poll-interval.
-SetDefaultswitch- Set the sandbox as your default org once it is ready. Adds --set-default.
-TargetOrgString- Username or alias of the production org that contains the sandbox license. Passed to sf as --target-org.
Salesforce CLI
sf org create sandbox
Examples
PS> Copy-SalesforceSandbox -SourceSandboxName dev1 -CloneSandboxName dev2 -TargetOrg prodClone dev1 as dev2.
Remarks
- To see the examples, type: "Get-Help Copy-SalesforceSandbox -Examples"
- For more information, type: "Get-Help Copy-SalesforceSandbox -Detailed"
- For technical information, type: "Get-Help Copy-SalesforceSandbox -Full"
- For online help, type: "Get-Help Copy-SalesforceSandbox -Online"
Related Links
- https://developer.salesforce.com/docs/platform/salesforce-cli-reference/guide/cli_reference.html
- https://github.com/salesforcecli/plugin-org
- https://github.com/tonygward/psfdx/blob/main/docs/cli-parity.md
- https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_commonparameters
Get-SalesforceSandboxes
Synopsis
Lists the sandboxes this computer is logged in to.
Syntax
Get-SalesforceSandboxes [[-Name] <String>] [<CommonParameters>]Description
Runs sf org list and returns the connected orgs that are sandboxes. With -Name, only those whose sandbox name, user name or alias equals it. It reads the local list of orgs; there is no -TargetOrg.
Parameters
-NameString- Keep only sandboxes whose sandbox name, user name or alias equals this value. The filter runs in PowerShell.
Salesforce CLI
sf org list
Examples
PS> Get-SalesforceSandboxesEvery sandbox this computer knows about.
Remarks
- To see the examples, type: "Get-Help Get-SalesforceSandboxes -Examples"
- For more information, type: "Get-Help Get-SalesforceSandboxes -Detailed"
- For technical information, type: "Get-Help Get-SalesforceSandboxes -Full"
- For online help, type: "Get-Help Get-SalesforceSandboxes -Online"
Related Links
- https://developer.salesforce.com/docs/platform/salesforce-cli-reference/guide/cli_reference.html
- https://github.com/salesforcecli/plugin-org
- https://github.com/tonygward/psfdx/blob/main/docs/cli-parity.md
- https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_commonparameters
Get-SalesforceSandboxRefreshStatus
Synopsis
Shows when a sandbox was last refreshed and its refresh state.
Syntax
Get-SalesforceSandboxRefreshStatus [-Name] <String> [[-TargetOrg] <String>] [<CommonParameters>]Description
Runs sf data query on the Tooling API objects SandboxInfo and SandboxProcess (two queries) for the sandbox name, and combines them. The name is escaped as a SOQL literal.
Parameters
-NameString, required- Name of the sandbox. Required.
-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.
Salesforce CLI
sf data query
Examples
PS> Get-SalesforceSandboxRefreshStatus -Name dev1 -TargetOrg prodThe refresh status of dev1.
Remarks
- To see the examples, type: "Get-Help Get-SalesforceSandboxRefreshStatus -Examples"
- For more information, type: "Get-Help Get-SalesforceSandboxRefreshStatus -Detailed"
- For technical information, type: "Get-Help Get-SalesforceSandboxRefreshStatus -Full"
- For online help, type: "Get-Help Get-SalesforceSandboxRefreshStatus -Online"
Related Links
- https://developer.salesforce.com/docs/platform/salesforce-cli-reference/guide/cli_reference.html
- https://github.com/salesforcecli/plugin-data
- https://github.com/tonygward/psfdx/blob/main/docs/cli-parity.md
- https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_commonparameters
New-SalesforceSandbox
Synopsis
Creates a sandbox from production.
Syntax
New-SalesforceSandbox [-SandboxName] <String> [[-Alias] <String>] [[-DefinitionFile] <String>] [[-LicenseType] <String>] [[-WaitMinutes] <Int32>] [-NoPrompt] [-NoTrackSource] [-Async] [[-PollIntervalSeconds] <Int32>] [-SetDefault] [[-SourceId] <String>] [[-TargetOrg] <String>] [<CommonParameters>]Description
Runs sf org create sandbox. A sandbox uses a license of your production org. The CLI waits only when you give -WaitMinutes; otherwise finish with Resume-SalesforceSandbox.
Parameters
-SandboxNameString, required- Name of the sandbox org. Passed to sf as --name. Required.
-AliasString- Alias for the sandbox org. Passed to sf as --alias.
-DefinitionFileString- Path to a sandbox definition file. Passed to sf as --definition-file.
-LicenseTypeString- Type of sandbox license. Passed to sf as --license-type. Default: Developer. Valid values: Developer, Developer_Pro, Partial, Full.
-WaitMinutesInt32- Number of minutes to wait for the sandbox org to be ready. Passed to sf as --wait.
-NoPromptswitch- Don't prompt for confirmation about the sandbox configuration. Adds --no-prompt.
-NoTrackSourceswitch- Do not use source tracking for this sandbox. Adds --no-track-source.
-Asyncswitch- Request the sandbox and return at once, without waiting for it to be ready. Finish with Resume-SalesforceSandbox. Adds --async.
-PollIntervalSecondsInt32- Number of seconds to wait between checks while waiting for the sandbox. Passed to sf as --poll-interval.
-SetDefaultswitch- Set the sandbox as your default org once it is ready. Adds --set-default.
-SourceIdString- ID of the sandbox to clone, as an alternative to -SourceSandboxName of Copy-SalesforceSandbox. Passed to sf as --source-id.
-TargetOrgString- Username or alias of the production org that contains the sandbox license. Passed to sf as --target-org.
Salesforce CLI
sf org create sandbox
Examples
PS> New-SalesforceSandbox -SandboxName dev2 -LicenseType Developer -TargetOrg prodCreate a developer sandbox.
Remarks
- To see the examples, type: "Get-Help New-SalesforceSandbox -Examples"
- For more information, type: "Get-Help New-SalesforceSandbox -Detailed"
- For technical information, type: "Get-Help New-SalesforceSandbox -Full"
- For online help, type: "Get-Help New-SalesforceSandbox -Online"
Related Links
- https://developer.salesforce.com/docs/platform/salesforce-cli-reference/guide/cli_reference.html
- https://github.com/salesforcecli/plugin-org
- https://github.com/tonygward/psfdx/blob/main/docs/cli-parity.md
- https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_commonparameters
Remove-SalesforceSandbox
Synopsis
Deletes a sandbox.
Syntax
Remove-SalesforceSandbox [-NoPrompt] [[-TargetOrg] <String>] [-WhatIf] [-Confirm] [<CommonParameters>]Description
Runs sf org delete sandbox. This cannot be undone. Asks for confirmation and supports -WhatIf; -NoPrompt also turns off the CLI's own question.
Parameters
-NoPromptswitch- Don't prompt the user to confirm the deletion. Adds --no-prompt.
-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.
-WhatIfswitch-Confirmswitch
Salesforce CLI
sf org delete sandbox
Examples
PS> Remove-SalesforceSandbox -TargetOrg dev2 -WhatIfPreview the delete.
Remarks
- To see the examples, type: "Get-Help Remove-SalesforceSandbox -Examples"
- For more information, type: "Get-Help Remove-SalesforceSandbox -Detailed"
- For technical information, type: "Get-Help Remove-SalesforceSandbox -Full"
- For online help, type: "Get-Help Remove-SalesforceSandbox -Online"
Related Links
- https://developer.salesforce.com/docs/platform/salesforce-cli-reference/guide/cli_reference.html
- https://github.com/salesforcecli/plugin-org
- https://github.com/tonygward/psfdx/blob/main/docs/cli-parity.md
- https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_commonparameters
Resume-SalesforceSandbox
Synopsis
Checks a sandbox creation and logs in to it when it is ready.
Syntax
Resume-SalesforceSandbox -SandboxName <String> [-WaitMinutes <Int32>] [-TargetOrg <String>] [<CommonParameters>]
Resume-SalesforceSandbox -JobId <String> [-WaitMinutes <Int32>] [-TargetOrg <String>] [<CommonParameters>]
Resume-SalesforceSandbox -UseMostRecent [-WaitMinutes <Int32>] [-TargetOrg <String>] [<CommonParameters>]Description
Runs sf org resume sandbox. Use it after New-SalesforceSandbox, Copy-SalesforceSandbox or Update-SalesforceSandbox returned without waiting. Say which sandbox with -SandboxName, with the -JobId of the sandbox process, or with -UseMostRecent for the latest one.
Parameters
-SandboxNameString, required- Name of the sandbox org. Passed to sf as --name. Required unless you give -JobId or -UseMostRecent.
-JobIdString, required- ID of the sandbox creation or refresh process (the SandboxProcess ID, starting 0GR). Passed to sf as --job-id. Use it instead of -SandboxName.
-UseMostRecentswitch, required- Resume the most recent sandbox creation or refresh. Adds --use-most-recent. Use it instead of -SandboxName.
-WaitMinutesInt32- Number of minutes to wait for the sandbox org to be ready. Passed to sf as --wait.
-TargetOrgString- Username or alias of the production org that contains the sandbox license. Passed to sf as --target-org.
Salesforce CLI
sf org resume sandbox
Examples
PS> Resume-SalesforceSandbox -SandboxName dev2 -WaitMinutes 30 -TargetOrg prodWait up to 30 minutes.
Remarks
- To see the examples, type: "Get-Help Resume-SalesforceSandbox -Examples"
- For more information, type: "Get-Help Resume-SalesforceSandbox -Detailed"
- For technical information, type: "Get-Help Resume-SalesforceSandbox -Full"
- For online help, type: "Get-Help Resume-SalesforceSandbox -Online"
Related Links
- https://developer.salesforce.com/docs/platform/salesforce-cli-reference/guide/cli_reference.html
- https://github.com/salesforcecli/plugin-org
- https://github.com/tonygward/psfdx/blob/main/docs/cli-parity.md
- https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_commonparameters
Update-SalesforceSandbox
Synopsis
Refreshes a sandbox from production or from another sandbox.
Syntax
Update-SalesforceSandbox [[-SandboxName] <String>] [[-DefinitionFile] <String>] [[-SourceSandboxName] <String>] [[-SourceId] <String>] [-NoAutoActivate] [-Async] [[-WaitMinutes] <Int32>] [[-PollIntervalSeconds] <Int32>] [-NoPrompt] [[-TargetOrg] <String>] [-WhatIf] [-Confirm] [<CommonParameters>]Description
Runs sf org refresh sandbox. A refresh replaces the sandbox's data and metadata with a fresh copy, so everything in it that is not in the source is lost. Asks for confirmation and supports -WhatIf; -NoPrompt skips the question. psfdx confirms first, so it always passes --no-prompt and the CLI does not ask a second time. The CLI waits only when you give -WaitMinutes; otherwise finish with Resume-SalesforceSandbox. Give the sandbox with -SandboxName, or put its name in a -DefinitionFile.
Parameters
-SandboxNameString- Name of the sandbox to refresh. Passed to sf as --name.
-DefinitionFileString- Path to a sandbox definition file that holds the refresh settings, such as the license type. Passed to sf as --definition-file.
-SourceSandboxNameString- Name of the sandbox to refresh from, instead of production. Passed to sf as --source-sandbox-name.
-SourceIdString- ID of the sandbox to refresh from, instead of its name. Passed to sf as --source-id.
-NoAutoActivateswitch- Do not activate the sandbox when the refresh finishes; you activate it yourself later. Adds --no-auto-activate.
-Asyncswitch- Start the refresh and return at once, without waiting for it to finish. Finish with Resume-SalesforceSandbox. Adds --async.
-WaitMinutesInt32- Number of minutes to wait for the refresh to finish. Passed to sf as --wait.
-PollIntervalSecondsInt32- Number of seconds to wait between checks while waiting for the refresh. Passed to sf as --poll-interval.
-NoPromptswitch- Don't ask for confirmation. Skips the PowerShell confirmation; psfdx always passes --no-prompt to the CLI after it has confirmed.
-TargetOrgString- Username or alias of the production org that owns the sandbox. Not required if the `target-org` configuration variable is already set. Passed to sf as --target-org.
-WhatIfswitch-Confirmswitch
Salesforce CLI
sf org refresh sandbox
Examples
PS> Update-SalesforceSandbox -SandboxName dev1 -TargetOrg prod -WhatIfPreview the refresh without starting it.
Remarks
- To see the examples, type: "Get-Help Update-SalesforceSandbox -Examples"
- For more information, type: "Get-Help Update-SalesforceSandbox -Detailed"
- For technical information, type: "Get-Help Update-SalesforceSandbox -Full"
- For online help, type: "Get-Help Update-SalesforceSandbox -Online"
Related Links
- https://developer.salesforce.com/docs/platform/salesforce-cli-reference/guide/cli_reference.html
- https://github.com/salesforcecli/plugin-org
- https://github.com/tonygward/psfdx/blob/main/docs/cli-parity.md
- https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_commonparameters
Scratch Orgs
Get-SalesforceScratchOrgs
Synopsis
Lists the scratch orgs this computer knows about.
Syntax
Get-SalesforceScratchOrgs [-SkipConnectionStatus] [-Last] [<CommonParameters>]Description
Runs sf org list --all and returns the scratch orgs. Every object has orgId, instanceUrl, username, connectedStatus, isDevHub, lastUsed and alias, plus any of these the CLI reports: expirationDate, isExpired, createdDate, createdBy, devHubUsername, devHubId, edition, status, orgName, namespace, signupUsername, aliases, instanceApiVersion, isDefaultUsername and similar non-secret details. Only these named properties are copied, so the access token in the CLI result is never returned. A CLI failure throws instead of returning nothing. With -Last only the most recently used one is returned.
Parameters
-SkipConnectionStatusswitch- Skip retrieving the connection status of non-scratch orgs. Adds --skip-connection-status.
-Lastswitch- Return only the scratch org with the latest lastUsed date. The sorting happens in PowerShell.
Salesforce CLI
sf org list
Examples
PS> Get-SalesforceScratchOrgs | Where-Object connectedStatus -eq 'Connected'Scratch orgs that are reachable.
Remarks
- To see the examples, type: "Get-Help Get-SalesforceScratchOrgs -Examples"
- For more information, type: "Get-Help Get-SalesforceScratchOrgs -Detailed"
- For technical information, type: "Get-Help Get-SalesforceScratchOrgs -Full"
- For online help, type: "Get-Help Get-SalesforceScratchOrgs -Online"
Related Links
- https://developer.salesforce.com/docs/platform/salesforce-cli-reference/guide/cli_reference.html
- https://github.com/salesforcecli/plugin-org
- https://github.com/tonygward/psfdx/blob/main/docs/cli-parity.md
- https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_commonparameters
New-SalesforceScratchOrg
Synopsis
Creates a scratch org.
Syntax
New-SalesforceScratchOrg [[-TargetDevHub] <String>] [-SetDefault] [[-DurationDays] <Int32>] [[-DefinitionFile] <String>] [[-WaitMinutes] <Int32>] [-Async] [[-Edition] <String>] [[-Snapshot] <String>] [[-AdminEmail] <String>] [[-Description] <String>] [[-Name] <String>] [[-Release] <String>] [[-SourceOrgId] <String>] [[-AdminUsername] <String>] [[-Alias] <String>] [[-OAuthClientId] <String>] [-NoAncestors] [-NoNamespace] [-NoTrackSource] [<CommonParameters>]Description
Runs sf org create scratch from a scratch org definition file. Use -Async to return before the org is ready, then finish with Resume-SalesforceScratchOrg. Scratch orgs use your Dev Hub's allocation and expire after the duration.
Parameters
-TargetDevHubString- Username or alias of the Dev Hub org. Passed to sf as --target-dev-hub.
-SetDefaultswitch- Set the scratch org as your default org. Adds --set-default.
-DurationDaysInt32- Number of days before the org expires. Passed to sf as --duration-days.
-DefinitionFileString- Path to a scratch org definition file. Passed to sf as --definition-file. Default: config/project-scratch-def.json.
-WaitMinutesInt32- Number of minutes to wait for the scratch org to be ready. Passed to sf as --wait.
-Asyncswitch- Request the org, but don't wait for it to complete. Adds --async.
-EditionString- Salesforce edition of the scratch org. Overrides the value of the "edition" option in the definition file, if set. Passed to sf as --edition. Valid values: developer, enterprise, group, professional, partner-developer, partner-enterprise, partner-group, partner-professional.
-SnapshotString- Name of the snapshot to use when creating this scratch org. Overrides the value of the "snapshot" option in the defintion file, if set. Passed to sf as --snapshot.
-AdminEmailString- Email address that will be applied to the org's admin user. Overrides the value of the "adminEmail" option in the definition file, if set. Passed to sf as --admin-email.
-DescriptionString- Description of the scratch org in the Dev Hub. Overrides the value of the "description" option in the definition file, if set. Passed to sf as --description.
-NameString- Name of the org, such as "Acme Company". Overrides the value of the "orgName" option in the definition file, if set. Passed to sf as --name.
-ReleaseString- Release of the scratch org as compared to the Dev Hub release. Passed to sf as --release. Valid values: preview, previous.
-SourceOrgIdString- 15-character ID of the org shape that the new scratch org is based on. Overrides the value of the "sourceOrg" option in the definition file, if set. Passed to sf as --source-org.
-AdminUsernameString- Username of the scratch org admin user. Overrides the value of the "username" option in the definition file, if set. Passed to sf as --username.
-AliasString- Alias for the scratch org. Passed to sf as --alias.
-OAuthClientIdString- OAuth client ID (also called consumer key) of your connected app, used to log in to the new scratch org. Passed to sf as --client-id.
-NoAncestorsswitch- Don't include second-generation managed package (2GP) ancestors in the scratch org. Adds --no-ancestors.
-NoNamespaceswitch- Create the scratch org without the namespace of the Dev Hub or the project, even if the project has one. Adds --no-namespace.
-NoTrackSourceswitch- Create the scratch org without source tracking. Scratch orgs have source tracking on by default. Adds --no-track-source.
Salesforce CLI
sf org create scratch
Examples
PS> New-SalesforceScratchOrg -DefinitionFile config/project-scratch-def.json -Name ci-1 -DurationDays 3 -SetDefaultCreate a three-day scratch org and make it the default.
Remarks
- To see the examples, type: "Get-Help New-SalesforceScratchOrg -Examples"
- For more information, type: "Get-Help New-SalesforceScratchOrg -Detailed"
- For technical information, type: "Get-Help New-SalesforceScratchOrg -Full"
- For online help, type: "Get-Help New-SalesforceScratchOrg -Online"
Related Links
- https://developer.salesforce.com/docs/platform/salesforce-cli-reference/guide/cli_reference.html
- https://github.com/salesforcecli/plugin-org
- https://github.com/tonygward/psfdx/blob/main/docs/cli-parity.md
- https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_commonparameters
Remove-SalesforceScratchOrg
Synopsis
Deletes a scratch org.
Syntax
Remove-SalesforceScratchOrg [-TargetOrg] <String> [-NoPrompt] [-WhatIf] [-Confirm] [<CommonParameters>]Description
Runs sf org delete scratch. This cannot be undone. Asks for confirmation and supports -WhatIf; -NoPrompt also turns off the CLI's own question.
Parameters
-TargetOrgString, required- Username or alias of the target org. Not required if the `target-org` configuration variable is already set. Passed to sf as --target-org. Required.
-NoPromptswitch- Don't prompt the user to confirm the deletion. Adds --no-prompt.
-WhatIfswitch-Confirmswitch
Salesforce CLI
sf org delete scratch
Examples
PS> Remove-SalesforceScratchOrg -TargetOrg ci-1 -WhatIfShow which org would be deleted.
Remarks
- To see the examples, type: "Get-Help Remove-SalesforceScratchOrg -Examples"
- For more information, type: "Get-Help Remove-SalesforceScratchOrg -Detailed"
- For technical information, type: "Get-Help Remove-SalesforceScratchOrg -Full"
- For online help, type: "Get-Help Remove-SalesforceScratchOrg -Online"
Related Links
- https://developer.salesforce.com/docs/platform/salesforce-cli-reference/guide/cli_reference.html
- https://github.com/salesforcecli/plugin-org
- https://github.com/tonygward/psfdx/blob/main/docs/cli-parity.md
- https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_commonparameters
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
Resume-SalesforceScratchOrg
Synopsis
Resumes a scratch org creation that was started with New-SalesforceScratchOrg -Async or that timed out (sf org resume scratch).
Syntax
Resume-SalesforceScratchOrg [[-JobId] <String>] [-UseMostRecent] [[-WaitMinutes] <Int32>] [<CommonParameters>]Description
Select the creation by -JobId (the scratch org info ID, starting 2SR, reported when the creation was started) or by -UseMostRecent. The CLI keeps a local record of the job, so there is no -TargetOrg; resume from the machine that started it. Returns the CLI result (org ID, username, instance URL) with Completed: true once the org is ready. A creation that is still running when -WaitMinutes ends (the CLI's StillInProgressError) returns Completed: false with Status InProgress, so a script can poll; a failed creation throws the CLI message. Permission sets are assigned afterwards with Grant-SalesforcePermissionSet (psfdx), which asks for confirmation.
Parameters
-JobIdString- Job ID of the incomplete scratch org create that you want to resume. Passed to sf as --job-id.
-UseMostRecentswitch- Resume the creation the CLI started most recently. Passed as --use-most-recent. Use instead of -JobId.
-WaitMinutesInt32- Number of minutes to wait for the scratch org to be ready. Passed to sf as --wait. Range: 1 to 1440.
Salesforce CLI
sf org resume scratch
Examples
PS> New-SalesforceScratchOrg -Async -Name ci-1 | Out-Null
PS> Resume-SalesforceScratchOrg -UseMostRecent -WaitMinutes 10
PS> Grant-SalesforcePermissionSet -Name MyPermSet -TargetOrg ci-1Remarks
- To see the examples, type: "Get-Help Resume-SalesforceScratchOrg -Examples"
- For more information, type: "Get-Help Resume-SalesforceScratchOrg -Detailed"
- For technical information, type: "Get-Help Resume-SalesforceScratchOrg -Full"
- For online help, type: "Get-Help Resume-SalesforceScratchOrg -Online"
Related Links
- https://developer.salesforce.com/docs/platform/salesforce-cli-reference/guide/cli_reference.html
- https://github.com/salesforcecli/plugin-org
- https://github.com/tonygward/psfdx/blob/main/docs/cli-parity.md
- https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_commonparameters
Further reference: repository command catalogue · Salesforce CLI parity report.
