Hi,
You should export the app list before Get-Content or you will read a file does not exist.
$path = 'C:\AppAssociations.xml'
$mail = '<Association Identifier="mailto" ProgId="AppXydk58wgm44se4b399557yyyj1w7mbmvd" ApplicationName="Mail" />'
$outlook = '<Association Identifier="mailto" ProgId="Outlook.URL.mailto.15" ApplicationName="Outlook" />'
# Download App Associations xml
Dism /online /Export-DefaultAppAssociations:"$path"
$con = Get-Content $path
# find and replace
$con | % { $_.Replace("$mail", "$outlook") } | Set-Content $path
# Import updated App Associations xml
Dism /online /Import-DefaultAppAssociations:$path
Get-Date
Best Regards,
Ian Xue
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.