Last active
June 20, 2021 17:13
-
-
Save toddboyd/7e9e906697e6f6afeeec2161fe2ad546 to your computer and use it in GitHub Desktop.
Create Scratch Org PowerShell Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param([string] $orgName, [int] $duration, [boolean]$debugMode) | |
if (!$orgName) { | |
# If no scratch org name is given, use a default name | |
$orgName = "defaultScratchOrgName"; | |
} | |
if (!$duration) { | |
# if no duration is provided, use default | |
$duration = "7"; | |
} | |
# Create Scratch Org | |
Write-Host -ForegroundColor green "Creating scratch org: $orgName..." | |
& sfdx force:org:create -a $orgName -d $duration -f config\project-scratch-def.json | |
if ($LASTEXITCODE -ne 0) { | |
exit 1 | |
} | |
if ($debugMode) { | |
# Set debug mode = true | |
Write-Host -ForegroundColor green "Setting debug mode..." | |
& Write-Output "update new User(Id = UserInfo.getUserId(), UserPreferencesUserDebugModePref=true);" | sfdx force:apex:execute -u $orgName | |
if ($LASTEXITCODE -ne 0) { | |
exit 1 | |
} | |
} | |
Write-Host "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment