We found some code and modified it to go through our SDE data and remove certain information such as server names from our metadata using the arcpy.XSLTransform_conversion and arcpy.MetadataImporter_conversion . The tools to do this process work from the application with each upgrade/new install however the scripting will fail because arcpy is looking for a couple of libraries in the GAC that are not registered.
Current environments do not have the gacutility and it can be difficult to find, so I found the instructions for using Powershell. I pass this on to all those who have a similar issue, you would think that ESRI would fix such a thing but metadata is obviously a low priority, look at how ArcGIS Pro is coming along in this area, disappointing.
------- What you need to know
The dlls are at YOURDDRIVE:\Program Files (x86)\ArcGIS\Desktop10.6\bin {10.6 would be whatever version}
MetadataTranslator.dll, GpMetadataFunctions.dll
Run Powershell in Admin mode and run commands, see below.
Comment: Startup system reflection
[System.Reflection.Assembly]::Load("System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
$publish = New-Object System.EnterpriseServices.Internal.Publish
Comment: use reflection to install dll into GAC. I moved the dll to temp location but that is not neccessary, it just makes the path a little less of a problem with all the spaces in the name etc.
$publish.GacInstall("c:\temp\MetadataTranslator.dll")
Comment: Note $publish.GacRemove should remove a library from GAC.
Verify install:
Comment: use reflection to confirm it has been added to GAC
([system.reflection.assembly]::loadfile("c:\temp\MetadataTranslator.dll")).FullName
Hi Louie,
I just wanted to say that I was having this exact problem (able to run in ArcCatalog but not via a script). After running the PowerShell commands, I was able to run the script.
Thank you very much!
Peggy