I am trying to create an array of Excel file basenames, as a string, to run through a foreach loop later in my script. I was able to generate the array but it includes the header "name" and is causing the script to error out. I am sure I did this in a goofy and more complicated way than needed.
I want to be sure to only grab Excel files dated within the last 2 days. Not pretty but it works as far as stripping the file name down to the base name but I don't know how to exclude the "[u]Name[/u]" header when I call the $table variable. I think my issue is the last Select-Object before the out-string, but not sure and not sure how else to do this.
+1 to using -expandproperty
There is a property called basename so there is no need to manually strip the xlsx
There is no need for out-string because the property you are expanding is already a string.
The first select-object is unnecessary
Thanks Kiran and Craig. While driving home I thought about the -expandproperty. I will add that and test. I also realized that now i have one long string rather than a series of names so i will revise again. I did have a filter at one point but must have deleted while trouble shooting. Thanks for pointing that out.