A comprehensive PowerShell module for interacting with Microsoft Dataverse environments. This module provides full CRUD operations, authentication management, and advanced querying capabilities for Dataverse tables and records.
- Multiple Authentication Methods: Support for Service Principal, Managed Identity, and Interactive authentication
- Comprehensive CRUD Operations: Create, Read, Update, and Delete operations for Dataverse records
- Advanced Querying: OData filters, field selection, record expansion, and automatic pagination
- Metadata Operations: Retrieve table and column metadata information
- Audit and Change Tracking: Access audit history and detailed change tracking
- PowerShell 7.3+ Compatible: Modern PowerShell support with Constrained Language Mode (CLM) compatibility
- PSScriptAnalyzer Compliant: Follows PowerShell best practices and coding standards
- PowerShell 7.3 or later
- Az.Accounts module 3.0.0 or later
- Appropriate permissions to access your Dataverse environment
-
Download or clone this repository
-
Copy the
Dataversefolder to one of your PowerShell module paths:- User modules:
$env:USERPROFILE\Documents\PowerShell\Modules\ - System modules:
$env:PROGRAMFILES\PowerShell\Modules\
- User modules:
-
Import the module:
Import-Module Dataverse
Get-Module Dataverse -ListAvailable
Get-Command -Module DataverseConnect-PSDVOrg -AzureTenantId "your-tenant-id" `
-SubscriptionId "your-subscription-id" `
-DataverseOrgURL "https://yourorg.crm.dynamics.com/" `
-Environment "AzureCloud"$secret = ConvertTo-SecureString "your-client-secret" -AsPlainText -Force
Connect-PSDVOrg -ClientID "your-client-id" `
-ClientSecret $secret `
-AzureTenantId "your-tenant-id" `
-DataverseOrgURL "https://yourorg.crm.dynamics.com/" `
-Environment "AzureCloud"# Get all accounts
Get-PSDVTableItem -Table "account"
# Get specific account by ID
Get-PSDVTableItem -Table "account" -ItemID "12345678-1234-1234-1234-123456789012"
# Filter records
Get-PSDVTableItem -Table "contact" -Filter "firstname eq 'John'"
# Select specific fields
Get-PSDVTableItem -Table "account" -Select @("name", "telephone1", "websiteurl")$accountData = @{
name = "Contoso Corporation"
accountnumber = "ACC001"
telephone1 = "555-123-4567"
}
New-PSDVTableItem -Table "account" -ItemData $accountData$updateData = @{
name = "Updated Company Name"
telephone1 = "555-987-6543"
}
Update-PSDVTableItem -Table "account" -ItemID "record-guid" -ItemData $updateDataRemove-PSDVTableItem -Table "account" -ItemID "record-guid"# Get all tables
Read-PSDVTableData
# Get detailed table metadata
Get-PSDVTableDetail -Table "account"
# Get column information
Get-PSDVTableColumn -Table "account"
# Get specific columns
Get-PSDVTableColumn -Table "account" -ColumnName @("name", "telephone1")Connect-PSDVOrg- Establish connection to DataverseUpdate-PSDVAccessToken- Refresh access token
Invoke-PSDVWebRequest- Execute authenticated web requestsGet-PSDVTableItem- Retrieve records from tablesNew-PSDVTableItem- Create new recordsUpdate-PSDVTableItem- Update existing recordsRemove-PSDVTableItem- Delete records
Read-PSDVTableData- Get all table metadataGet-PSDVTableDetail- Get detailed table informationGet-PSDVTableColumn- Get column metadata
Get-PSDVTableItemAuditHistory- Get audit historyGet-PSDVTableItemChangeHistory- Get detailed change history
# Get accounts with revenue over $1M and include primary contact
Get-PSDVTableItem -Table "account" `
-Filter "revenue gt 1000000" `
-Expand "primarycontactid" `
-Select @("name", "revenue", "primarycontactid")# Create contact with parent account lookup
$contactData = @{
firstname = "John"
lastname = "Doe"
emailaddress1 = "john.doe@contoso.com"
parentcustomerid = "account-guid"
}
New-PSDVTableItem -Table "contact" -ItemData $contactData -ParseItemData# Get complete audit history for a record
Get-PSDVTableItemAuditHistory -Table "account" -ItemID "record-guid"
# Get detailed change history
Get-PSDVTableItemChangeHistory -Table "account" -ItemID "record-guid"The module includes comprehensive error handling with meaningful error messages. Common patterns:
try {
$result = Get-PSDVTableItem -Table "account" -ItemID "invalid-guid"
}
catch {
Write-Error "Failed to retrieve account: $($_.Exception.Message)"
}- Use Service Principal authentication for automated scenarios
- Store secrets securely using PowerShell SecureString or Azure Key Vault
- Follow the principle of least privilege for Dataverse permissions
- The module is compatible with PowerShell Constrained Language Mode (CLM)
- Authentication Errors: Ensure correct tenant ID, client ID, and permissions
- Table Not Found: Verify table logical names and case sensitivity
- Permission Denied: Check Dataverse security roles and permissions
- Token Expiration: The module automatically handles token refresh
# Enable verbose output for troubleshooting
Get-PSDVTableItem -Table "account" -VerboseThis module follows PowerShell best practices and PSScriptAnalyzer rules. When contributing:
- Ensure PowerShell 7.3+ compatibility
- Follow the existing code style and patterns
- Include comprehensive help documentation
- Test in both normal and Constrained Language Mode environments
[Specify your license here]
[Specify support information here]
- Initial release
- Support for all major Dataverse operations
- Multiple authentication methods
- Comprehensive help documentation
- PSScriptAnalyzer compliance
- Constrained Language Mode compatibility