I searched for the solution below, but nothing specific can be found.
I have a PowerHail script that checks the content of an XML file that is manually created / edited by humans for any illegal characters and has been replaced with non-illegal characters. . It uses the Get -Content and Set -Content command as the following. It then copies the file from one place to another.
(Get-Content 'C: \ SourceLocation \ filename.xml') | Foreach-Object {$ _-replace "& amp;", "+" `-place" "£", "GBP" `'' ',' ',' '' '-' ',' '' '" '' '' - '' (? & Lt;! \? Xml. *) (? & Lt; = `". *?) `'(? =. *?' ')", ""} | Set-content 'C: \ SourceLocation \ filename.xml' per-item-path 'C: \ SourceLocation \ filename.xml' -nation 'C: \ DestinationLocation \ filename.xml'
I want to modify the script so that it only runs set-content command (prevents the file) if any letters have been changed. The copy command still needs to run the script every time, even if no letter has been changed or not.
Thank you,
Ladders
Do you mean something
$ b = ($ a = get-content 'C: \ SourceLocation \ filename.xml') | The last object {$ _-replace "and", "+" `-replace '" - "" -rele "", "" -rele "(? & Lt;! \? Xml. *) (? & Lt; = '' (? *?) '' (? =? *? '') "," "} If (Compare $$$ B-PassThru) {$ b | Set-Content 'C: \ SourceLocation \ filename.xml '} Copy-item-path' C: \ SourceLocation \ filename.xml '-Nation' C: \ DestinationLocation \ filename.xml '
Comments
Post a Comment