0

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.

1 Answer 1

1

Pipe Get-ChildItem to select-object :

$source=Get-ChildItem "$source_path\\CUST_MEA_*.csv" | select  -Last 1
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.