Concatenate string and result of expression inside a powershell command The Next CEO of Stack OverflowString concatenation: concat() vs “+” operatorHow to concatenate a std::string and an int?StringBuilder vs String concatenation in toString() in JavaHow to handle command-line arguments in PowerShellPython String and Integer concatenationConcatenate item in list to stringsHow do I concatenate strings and variables in PowerShell?How to execute a powershell with '-command' argument in administration modePowershell encode with powershell commandsCURL command to translate in Powershell or VBS

How can I get through very long and very dry, but also very useful technical documents when learning a new tool?

Term for the "extreme-extension" version of a straw man fallacy?

Go Pregnant or Go Home

What does "Its cash flow is deeply negative" mean?

What is the difference between "behavior" and "behaviour"?

How to write papers efficiently when English isn't my first language?

What does this shorthand mean?

Text adventure game code

Rotate a column

How to write the block matrix in LaTex?

Robert Sheckley short story about vacation spots being overwhelmed

How to safely derail a train during transit?

I believe this to be a fraud - hired, then asked to cash check and send cash as Bitcoin

What happens if you roll doubles 3 times then land on "Go to jail?"

Why didn't Theresa May consult with Parliament before negotiating a deal with the EU?

Is the concept of a "numerable" fiber bundle really useful or an empty generalization?

Why does standard notation not preserve intervals (visually)

What do "high sea" and "carry" mean in this sentence?

Fastest way to shutdown Ubuntu Mate 18.10

The King's new dress

How to be diplomatic in refusing to write code that breaches the privacy of our users

Would this house-rule that treats advantage as a +1 to the roll instead (and disadvantage as -1) and allows them to stack be balanced?

WOW air has ceased operation, can I get my tickets refunded?

Unreliable Magic - Is it worth it?



Concatenate string and result of expression inside a powershell command



The Next CEO of Stack OverflowString concatenation: concat() vs “+” operatorHow to concatenate a std::string and an int?StringBuilder vs String concatenation in toString() in JavaHow to handle command-line arguments in PowerShellPython String and Integer concatenationConcatenate item in list to stringsHow do I concatenate strings and variables in PowerShell?How to execute a powershell with '-command' argument in administration modePowershell encode with powershell commandsCURL command to translate in Powershell or VBS










0















I have this code



powershell -Command "(gc "E:DesktopNuovaanag.xml") -replace '<Revocato>true</Revocato>', (Get-Date).AddDays(-1).ToString('MM-dd-yyyy') | set-content "E:DesktopNuovaanag.xml""


That returns 03-07-2019



But I want it to return <Revocato>03-07-2019</Revocato>



I tried different approaches, like using as second replace parameter '<Revocato>0</Revocato>' -f ((Get-Date).AddDays(-1).ToString('MM-dd-yyyy')) and few other ideas, but nothing return the result I want. Any help please?










share|improve this question



















  • 2





    Have you tried using an actual XML parser?

    – Ansgar Wiechers
    Mar 7 at 14:11











  • Does this help '<Revocato>true</Revocato>' -replace '<Revocato>true</Revocato>', "<Revocato>$((Get-Date).AddDays(-1).ToString('MM-dd-yyyy'))</Revocato>" Else, can you share the XML?

    – jfrmilner
    Mar 7 at 14:25












  • (gc "revocato.xml") -replace "(?m)^.*(<Revocato>.*)(true.*)(</Revocato>.*)$", ("$1~$((Get-Date).AddDays(-1).ToString('MM-dd-yyyy'))~$3") -replace '~',''

    – f6a4
    Mar 7 at 15:05











  • @f6a4 thanks it works! :) Make it an answer so I can mark it as solution

    – Gabriele Cozzolino
    Mar 8 at 7:38
















0















I have this code



powershell -Command "(gc "E:DesktopNuovaanag.xml") -replace '<Revocato>true</Revocato>', (Get-Date).AddDays(-1).ToString('MM-dd-yyyy') | set-content "E:DesktopNuovaanag.xml""


That returns 03-07-2019



But I want it to return <Revocato>03-07-2019</Revocato>



I tried different approaches, like using as second replace parameter '<Revocato>0</Revocato>' -f ((Get-Date).AddDays(-1).ToString('MM-dd-yyyy')) and few other ideas, but nothing return the result I want. Any help please?










share|improve this question



















  • 2





    Have you tried using an actual XML parser?

    – Ansgar Wiechers
    Mar 7 at 14:11











  • Does this help '<Revocato>true</Revocato>' -replace '<Revocato>true</Revocato>', "<Revocato>$((Get-Date).AddDays(-1).ToString('MM-dd-yyyy'))</Revocato>" Else, can you share the XML?

    – jfrmilner
    Mar 7 at 14:25












  • (gc "revocato.xml") -replace "(?m)^.*(<Revocato>.*)(true.*)(</Revocato>.*)$", ("$1~$((Get-Date).AddDays(-1).ToString('MM-dd-yyyy'))~$3") -replace '~',''

    – f6a4
    Mar 7 at 15:05











  • @f6a4 thanks it works! :) Make it an answer so I can mark it as solution

    – Gabriele Cozzolino
    Mar 8 at 7:38














0












0








0








I have this code



powershell -Command "(gc "E:DesktopNuovaanag.xml") -replace '<Revocato>true</Revocato>', (Get-Date).AddDays(-1).ToString('MM-dd-yyyy') | set-content "E:DesktopNuovaanag.xml""


That returns 03-07-2019



But I want it to return <Revocato>03-07-2019</Revocato>



I tried different approaches, like using as second replace parameter '<Revocato>0</Revocato>' -f ((Get-Date).AddDays(-1).ToString('MM-dd-yyyy')) and few other ideas, but nothing return the result I want. Any help please?










share|improve this question
















I have this code



powershell -Command "(gc "E:DesktopNuovaanag.xml") -replace '<Revocato>true</Revocato>', (Get-Date).AddDays(-1).ToString('MM-dd-yyyy') | set-content "E:DesktopNuovaanag.xml""


That returns 03-07-2019



But I want it to return <Revocato>03-07-2019</Revocato>



I tried different approaches, like using as second replace parameter '<Revocato>0</Revocato>' -f ((Get-Date).AddDays(-1).ToString('MM-dd-yyyy')) and few other ideas, but nothing return the result I want. Any help please?







powershell windows-10 concatenation






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 7 at 14:26









Dominique

2,23442042




2,23442042










asked Mar 7 at 14:06









Gabriele CozzolinoGabriele Cozzolino

9712




9712







  • 2





    Have you tried using an actual XML parser?

    – Ansgar Wiechers
    Mar 7 at 14:11











  • Does this help '<Revocato>true</Revocato>' -replace '<Revocato>true</Revocato>', "<Revocato>$((Get-Date).AddDays(-1).ToString('MM-dd-yyyy'))</Revocato>" Else, can you share the XML?

    – jfrmilner
    Mar 7 at 14:25












  • (gc "revocato.xml") -replace "(?m)^.*(<Revocato>.*)(true.*)(</Revocato>.*)$", ("$1~$((Get-Date).AddDays(-1).ToString('MM-dd-yyyy'))~$3") -replace '~',''

    – f6a4
    Mar 7 at 15:05











  • @f6a4 thanks it works! :) Make it an answer so I can mark it as solution

    – Gabriele Cozzolino
    Mar 8 at 7:38













  • 2





    Have you tried using an actual XML parser?

    – Ansgar Wiechers
    Mar 7 at 14:11











  • Does this help '<Revocato>true</Revocato>' -replace '<Revocato>true</Revocato>', "<Revocato>$((Get-Date).AddDays(-1).ToString('MM-dd-yyyy'))</Revocato>" Else, can you share the XML?

    – jfrmilner
    Mar 7 at 14:25












  • (gc "revocato.xml") -replace "(?m)^.*(<Revocato>.*)(true.*)(</Revocato>.*)$", ("$1~$((Get-Date).AddDays(-1).ToString('MM-dd-yyyy'))~$3") -replace '~',''

    – f6a4
    Mar 7 at 15:05











  • @f6a4 thanks it works! :) Make it an answer so I can mark it as solution

    – Gabriele Cozzolino
    Mar 8 at 7:38








2




2





Have you tried using an actual XML parser?

– Ansgar Wiechers
Mar 7 at 14:11





Have you tried using an actual XML parser?

– Ansgar Wiechers
Mar 7 at 14:11













Does this help '<Revocato>true</Revocato>' -replace '<Revocato>true</Revocato>', "<Revocato>$((Get-Date).AddDays(-1).ToString('MM-dd-yyyy'))</Revocato>" Else, can you share the XML?

– jfrmilner
Mar 7 at 14:25






Does this help '<Revocato>true</Revocato>' -replace '<Revocato>true</Revocato>', "<Revocato>$((Get-Date).AddDays(-1).ToString('MM-dd-yyyy'))</Revocato>" Else, can you share the XML?

– jfrmilner
Mar 7 at 14:25














(gc "revocato.xml") -replace "(?m)^.*(<Revocato>.*)(true.*)(</Revocato>.*)$", ("$1~$((Get-Date).AddDays(-1).ToString('MM-dd-yyyy'))~$3") -replace '~',''

– f6a4
Mar 7 at 15:05





(gc "revocato.xml") -replace "(?m)^.*(<Revocato>.*)(true.*)(</Revocato>.*)$", ("$1~$((Get-Date).AddDays(-1).ToString('MM-dd-yyyy'))~$3") -replace '~',''

– f6a4
Mar 7 at 15:05













@f6a4 thanks it works! :) Make it an answer so I can mark it as solution

– Gabriele Cozzolino
Mar 8 at 7:38






@f6a4 thanks it works! :) Make it an answer so I can mark it as solution

– Gabriele Cozzolino
Mar 8 at 7:38













0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55045716%2fconcatenate-string-and-result-of-expression-inside-a-powershell-command%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55045716%2fconcatenate-string-and-result-of-expression-inside-a-powershell-command%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

1928 у кіно

Захаров Федір Захарович

Ель Греко