Add sf-org-lic: Salesforce license utilization reporting tool

- New sf-org-lic script for comprehensive license reporting
- Generates reports for User Licenses and Permission Set Licenses
- Enhanced error handling with org validation and clear error messages
- Follows consistent sf-org-* naming convention with -to/-hp options
- Professional formatted output with totals and color coding
- Removed problematic FeatureLicense queries (not available in most orgs)
- Updated README.md with full documentation and installation instructions

Fixes issues with original sf-licenses-report.sh:
- Silent failures when org doesn't exist
- Poor error handling and cryptic messages
- SOQL query issues with FIELDS(ALL)
- Inconsistent naming convention
This commit is contained in:
app
2025-09-01 23:39:26 +08:00
parent c19d8bfe9d
commit fafc8fac20
2 changed files with 234 additions and 1 deletions

View File

@@ -20,6 +20,7 @@ Authentication:
Org and metadata:
- **[`sf-org-create` / `sf-org-create.ps1`](#sf-org-create)** - Smart scratch org creation
- **[`sf-org-lic`](#sf-org-lic)** - Salesforce org license utilization report
- **[`sf-org-info` / `sf-org-info.ps1`](#sf-org-info--sf-org-infops1)** - Quick org info, limits, and context
- **[`sf-retrieve` / `sf-retrieve.ps1`](#sf-retrieve--sf-retrieveps1)** - Streamlined metadata retrieval (types, manifest, packages)
@@ -83,7 +84,7 @@ sf-data-export -qy "SELECT Id FROM Account" -to myorg -fm csv
```bash
chmod +x \
sf-deploy sf-dry-run sf-web-open sf-web-login sf-web-logout sf-check \
sf-org-create sf-org-info sf-retrieve sf-test-run sf-apex-run \
sf-org-create sf-org-lic sf-org-info sf-retrieve sf-test-run sf-apex-run \
sf-data-export sf-data-import sf-logs-tail
```
3. Add the directory to your PATH or create symlinks in a directory that's already in your PATH:
@@ -99,6 +100,7 @@ ln -s /path/to/sf-cli-wrapper/sf-web-login /usr/local/bin/sf-web-login
ln -s /path/to/sf-cli-wrapper/sf-web-logout /usr/local/bin/sf-web-logout
ln -s /path/to/sf-cli-wrapper/sf-check /usr/local/bin/sf-check
ln -s /path/to/sf-cli-wrapper/sf-org-create /usr/local/bin/sf-org-create
ln -s /path/to/sf-cli-wrapper/sf-org-lic /usr/local/bin/sf-org-lic
ln -s /path/to/sf-cli-wrapper/sf-org-info /usr/local/bin/sf-org-info
ln -s /path/to/sf-cli-wrapper/sf-retrieve /usr/local/bin/sf-retrieve
ln -s /path/to/sf-cli-wrapper/sf-test-run /usr/local/bin/sf-test-run
@@ -174,6 +176,46 @@ sf-org-create -al TestOrg -dd 5 -nn
---
### <a id="sf-org-lic"></a>[🏠](#salesforce-cli-wrapper-scripts) sf-org-lic
Generate comprehensive Salesforce license utilization reports.
**Usage:**
```bash
sf-org-lic -to ORG [-hp]
```
**Options:**
- `-to` - Target org alias or username (required)
- `-hp` - Show help message
**Examples:**
```bash
# Generate license report for production org
sf-org-lic -to PROD-ORG
# Generate report for specific user
sf-org-lic -to admin@company.com
# Show help
sf-org-lic -hp
```
**Features:**
- **User Licenses** - Core Salesforce user license utilization
- **Permission Set Licenses** - Add-on feature license usage
- **Comprehensive totals** - Overall usage summary with remaining capacity
- **Clean formatting** - Professional tabular output
- **Error handling** - Clear messages for invalid orgs with suggestions
**Output includes:**
- License name, total allocated, used count, and remaining capacity
- Color-coded totals summary
- Professional formatting suitable for reports
---
### <a id="sf-org-info--sf-org-infops1"></a>[🏠](#salesforce-cli-wrapper-scripts) sf-org-info / sf-org-info.ps1
Display org information, limits, and list authenticated orgs.