Reputation: 2301
My script will read specify file which I have defined in the variables.
$source_path = "D:\Data\CUST"
$source = "$source_path\CUST_MEA_20160228.csv"
Now, I have new case which everyday I will received CUST_MEA_{DATE} from source system. This file will saved in D:\Data folders. Then when reaching reporting time, my script will go to the folder D:\Data to get lasted modified CUST_MEA file and process that particular file. Example I have CUST_MEA_20160222 and CUST_MEA_20160223, The script will go read CUST_MEA_20160223 and process it.
Now my problem is how to tell powershell to assign filename which is CUST_MEA_20160223 to variable $source.
Upvotes: 0
Views: 2318
Reputation: 408
Pipe Get-ChildItem to select-object :
$source=Get-ChildItem "$source_path\\CUST_MEA_*.csv" | select -Last 1
Upvotes: 1