replace text in file using wildcardsHi there, i have next text in my file *20090623* this is date, i need change this text every day, so i wrote next code<br/><br/>$getdate_curr=get-date -format yyyMMdd (assign to variable current date in required format) and then i'm trying replace old date to new one<br/><br/>(Get-Content D:\I\moveit\config.par) | <br/>Foreach-Object {$_ -replace &quot;2009*\*&quot;,$getdate_curr} | <br/>Set-Content D:\I\moveit\config.par<br/><br/>It's work incorrectly, how can i change this code?<br/><br/>Thank you.© 2009 Microsoft Corporation. All rights reserved.Thu, 25 Jun 2009 06:31:56 Z79b3ca64-7767-4357-bf1e-10ed5e844ed1http://social.technet.microsoft.com/Forums/en-US/winserverpowershell/thread/79b3ca64-7767-4357-bf1e-10ed5e844ed1#79b3ca64-7767-4357-bf1e-10ed5e844ed1http://social.technet.microsoft.com/Forums/en-US/winserverpowershell/thread/79b3ca64-7767-4357-bf1e-10ed5e844ed1#79b3ca64-7767-4357-bf1e-10ed5e844ed1mnemonicatorhttp://social.technet.microsoft.com/Profile/en-US/?user=mnemonicatorreplace text in file using wildcardsHi there, i have next text in my file *20090623* this is date, i need change this text every day, so i wrote next code<br/><br/>$getdate_curr=get-date -format yyyMMdd (assign to variable current date in required format) and then i'm trying replace old date to new one<br/><br/>(Get-Content D:\I\moveit\config.par) | <br/>Foreach-Object {$_ -replace &quot;2009*\*&quot;,$getdate_curr} | <br/>Set-Content D:\I\moveit\config.par<br/><br/>It's work incorrectly, how can i change this code?<br/><br/>Thank you.Wed, 24 Jun 2009 11:18:18 Z2009-06-24T11:18:18Zhttp://social.technet.microsoft.com/Forums/en-US/winserverpowershell/thread/79b3ca64-7767-4357-bf1e-10ed5e844ed1#fe17b11d-0237-47c9-a582-cb3390da9f8ehttp://social.technet.microsoft.com/Forums/en-US/winserverpowershell/thread/79b3ca64-7767-4357-bf1e-10ed5e844ed1#fe17b11d-0237-47c9-a582-cb3390da9f8eMarco Shawhttp://social.technet.microsoft.com/Profile/en-US/?user=Marco%20Shawreplace text in file using wildcardsAre you always replacing the date from the day before?  I'm thinking you would create a variable for yesterday and today, and then use those variables in the replace to do an exact replacement.Wed, 24 Jun 2009 11:56:48 Z2009-06-24T11:56:48Zhttp://social.technet.microsoft.com/Forums/en-US/winserverpowershell/thread/79b3ca64-7767-4357-bf1e-10ed5e844ed1#32f38d54-df4f-4f7f-89e3-45a64967299bhttp://social.technet.microsoft.com/Forums/en-US/winserverpowershell/thread/79b3ca64-7767-4357-bf1e-10ed5e844ed1#32f38d54-df4f-4f7f-89e3-45a64967299bmnemonicatorhttp://social.technet.microsoft.com/Profile/en-US/?user=mnemonicatorreplace text in file using wildcards<p>yes, you are correct. i'll try to do this, it's my first steps in PS...</p>Wed, 24 Jun 2009 14:36:17 Z2009-06-24T14:36:17Zhttp://social.technet.microsoft.com/Forums/en-US/winserverpowershell/thread/79b3ca64-7767-4357-bf1e-10ed5e844ed1#37964d43-fdd7-46f4-b479-8462031f3008http://social.technet.microsoft.com/Forums/en-US/winserverpowershell/thread/79b3ca64-7767-4357-bf1e-10ed5e844ed1#37964d43-fdd7-46f4-b479-8462031f3008Marco Shawhttp://social.technet.microsoft.com/Profile/en-US/?user=Marco%20Shawreplace text in file using wildcardsCheck this out:<br/> <pre lang="x-c#">$today=get-date -format yyyMMdd $today $yesterday=(get-date).adddays(-1)|%{ if($_.month -lt 10){$month=[string]0+$_.month}else{$month=$_.month} if($_.day -lt 10){$day=[string]0+$_.day}else{$day=$_.day} [string]$_.year+[string]$month+[string]$day } $yesterday &quot;$yesterday&quot;.replace($yesterday,$today)</pre> Using the format you're looking for to calculate yesterday is a PAIN!  Maybe there's an easier though.<br/> <br/> That should help you out...<br/>Wed, 24 Jun 2009 18:41:08 Z2009-06-24T18:41:08Zhttp://social.technet.microsoft.com/Forums/en-US/winserverpowershell/thread/79b3ca64-7767-4357-bf1e-10ed5e844ed1#3a2b21b3-0bd4-47d6-8e03-eda2e1046814http://social.technet.microsoft.com/Forums/en-US/winserverpowershell/thread/79b3ca64-7767-4357-bf1e-10ed5e844ed1#3a2b21b3-0bd4-47d6-8e03-eda2e1046814mnemonicatorhttp://social.technet.microsoft.com/Profile/en-US/?user=mnemonicatorreplace text in file using wildcardsthank you so much.Thu, 25 Jun 2009 06:31:56 Z2009-06-25T06:31:56Z