Has anyone used powershell to move word docs from one environment to another? I don't want to use xrmtoolbox, if possible.
Has anyone used powershell to move word docs from one environment to another? I don't want to use xrmtoolbox, if possible.
hi
it is possible to use PowerShell to move Word documents from one environment to another in Dynamics 365. Here's a basic script that you can use as a starting point:
powershell:
# Set variables
$sourceUrl = "source.crm.dynamics.com"
$sourceUsername = "sourceuser@domain.com"
$sourcePassword = "sourcepassword"
$sourceDocumentLibraryName = "Documents"
$sourceDocumentName = "MyDocument.docx"
$destinationUrl = "destination.crm.dynamics.com"
$destinationUsername = "destinationuser@domain.com"
$destinationPassword = "destinationpassword"
$destinationDocumentLibraryName = "Documents"
# Get source file
$sourceContext = New-Object Microsoft.PowerShell.Commands.WebRequestSession
$sourceContext.Credentials = New-Object System.Net.NetworkCredential($sourceUsername, $sourcePassword)
$sourceFileUrl = "$sourceUrl/$sourceDocumentLibraryName/$sourceDocumentName"
$sourceFileContent = Invoke-WebRequest -Uri $sourceFileUrl -WebSession $sourceContext
$sourceFileBytes = [System.Convert]::FromBase64String($sourceFileContent.Content)
# Upload file to destination
$destinationContext = New-Object Microsoft.PowerShell.Commands.WebRequestSession
$destinationContext.Credentials = New-Object System.Net.NetworkCredential($destinationUsername, $destinationPassword)
$destinationFileUrl = "$destinationUrl/$destinationDocumentLibraryName/$sourceDocumentName"
Invoke-RestMethod -Uri $destinationFileUrl -Method Put -Body $sourceFileBytes -WebSession $destinationContext
You'll need to replace the values of the variables at the top of the script with your own environment information. The script uses the Invoke-WebRequest cmdlet to download the file from the source environment and the Invoke-RestMethod cmdlet to upload it to the destination environment.
DAniele
Hi brownfield1,
Or you can try to migrate data between Microsoft Dataverse environments using the dataflows OData connector
Adis
136
Super User 2025 Season 1
Sohail Ahmed
81
Jonas "Jones" Melgaard
77
Super User 2025 Season 1