Using a loop to concatenate array strings with a variable in powershell

$strYesterdays_Date_4yr_First = ((Get-Date).AddDays(-1)).ToString("yyyyMMdd")

$Atemp_file_names = @("userrnlg.","cpauditd.","auditclinician.","useraudl.","auditlog.")

for ($i=0;$i -lt $Atemp_file_names.Length; $i++){
  $Atemp_file_names[$i] = "$Atemp_file_names[$i]$strYesterdays_Date_4yr_First"
  Write-host $Atemp_file_names[$i]
} 

I'm trying to use for loop to concatenate each array element (string) with yesterday's date. I must be missing something, as the elements are not being modified. Any suggestions?

Answers


$strYesterdays_Date_4yr_First = ((Get-Date).AddDays(-1)).ToString("yyyyMMdd")

$Atemp_file_names = @("userrnlg.","cpauditd.","auditclinician.","useraudl.","auditlog.")

for ($i=0;$i -lt $Atemp_file_names.Length; $i++){
  $Atemp_file_names[$i] = $Atemp_file_names[$i] + $strYesterdays_Date_4yr_First
  Write-host $Atemp_file_names[$i]
}

I figured it out, but thought I'd already had tried it this way. Now I'm going to try using a foreach loop and see if I can make that work!


Need Your Help

Sibling subview does not receive touches in iPhone

iphone ios uiview touchesbegan uiresponder

I have a view (parent) with two subviews, one on top (topChild) of the other (bottomChild).

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.