Hi,
I'm trying to create a conversion plug-in which uses Powershell to perform some custom normalization on xml documents before comparing them, but I'm having some trouble getting it to work properly.
I think the problem is to do with the security context that BeyondCompare launches external programs in, and my Powershell execution policy, but I've run out of ideas on what it might be.
Starting from the beginning, I created a File Format which handles the xml extension as follows:
Name: Xml (Loose Comparison)
Mask: *.config; *.xml
Conversion: External program (Unicode filenames)
Loading: C:\temp\myscript.cmd "%s" "%t"
And the batch file "myscript.cmd" contains the following line which calls the PowerShell script and pipes the output to the temp file passed in by BeyondCompare:
%powershell% "&'C:\temp\myscipt.ps1'" "%1" ^> "%2"
I've used SysInternals Procmon to check what's going on and the following process gets started:
cmd /c ""C:\temp\myscript.cmd" "c:\docs\myfile.xml" "C:\Users\myaccount\AppData\Local\Temp\BC35FC1.tmp ""
which then launches the powershell script:
"C:\Windows\System32\WindowsPowerShell\v1.0\powers hell.exe" "&'C:\temp\myscript.ps1'" ""c:\docs\myfile.xml""
and the temp file gets created but it contains the following text:
"File F:\temp\normalize-xml.ps1 cannot be loaded because the execution of scripts is disabled on this system. Please see "get-help about_signing" for
more details.
At line:1 char:2
+ & <<<< 'C:\temp\myscript.ps1' c:\docs\myfile.xml
+ CategoryInfo : NotSpecified: ( [], PSSecurityException
+ FullyQualifiedErrorId : RuntimeException"
If I try running the same command "cmd /c ""C:\temp\myscript.cmd" "c:\docs\myfile.xml" "C:\Users\myaccount\AppData\Local\Temp\BC35FC1.tmp """ from the command line it works and the temp file creates the converted xml.
The execution policy for Powershell on my machine is set to "RemoteSigned", but I tried "Unrestricted" and got the same problem. I've also tried running BeyondCompare as an administrator but again it still puts the error message into the temp file.
I'm not sure what else to try at this point - does anyone have any suggestions?
Cheers,
Mike
I'm trying to create a conversion plug-in which uses Powershell to perform some custom normalization on xml documents before comparing them, but I'm having some trouble getting it to work properly.
I think the problem is to do with the security context that BeyondCompare launches external programs in, and my Powershell execution policy, but I've run out of ideas on what it might be.
Starting from the beginning, I created a File Format which handles the xml extension as follows:
Name: Xml (Loose Comparison)
Mask: *.config; *.xml
Conversion: External program (Unicode filenames)
Loading: C:\temp\myscript.cmd "%s" "%t"
And the batch file "myscript.cmd" contains the following line which calls the PowerShell script and pipes the output to the temp file passed in by BeyondCompare:
%powershell% "&'C:\temp\myscipt.ps1'" "%1" ^> "%2"
I've used SysInternals Procmon to check what's going on and the following process gets started:
cmd /c ""C:\temp\myscript.cmd" "c:\docs\myfile.xml" "C:\Users\myaccount\AppData\Local\Temp\BC35FC1.tmp ""
which then launches the powershell script:
"C:\Windows\System32\WindowsPowerShell\v1.0\powers hell.exe" "&'C:\temp\myscript.ps1'" ""c:\docs\myfile.xml""
and the temp file gets created but it contains the following text:
"File F:\temp\normalize-xml.ps1 cannot be loaded because the execution of scripts is disabled on this system. Please see "get-help about_signing" for
more details.
At line:1 char:2
+ & <<<< 'C:\temp\myscript.ps1' c:\docs\myfile.xml
+ CategoryInfo : NotSpecified: ( [], PSSecurityException
+ FullyQualifiedErrorId : RuntimeException"
If I try running the same command "cmd /c ""C:\temp\myscript.cmd" "c:\docs\myfile.xml" "C:\Users\myaccount\AppData\Local\Temp\BC35FC1.tmp """ from the command line it works and the temp file creates the converted xml.
The execution policy for Powershell on my machine is set to "RemoteSigned", but I tried "Unrestricted" and got the same problem. I've also tried running BeyondCompare as an administrator but again it still puts the error message into the temp file.
I'm not sure what else to try at this point - does anyone have any suggestions?
Cheers,
Mike
Comment