Powershell help

I have been attempting to write a powershell* script to rename files. We are having our students turn in assignments to collect documents needed for in-processing with Blackboard and it works very well except for the fact that when you batch download (in a zip file) Blackboard puts a bunch of crap in the name before the name we told the students to save the file with.
We tell them to save the file with names in the following format: Lastname_SDS.pdf where Lastname is the students last name and what is after the _ is the form name. so here is an example of what blackboard spits out:
Student Data sheet_steve.e.goofazoid_attempt_2019-05-21-19-39-49_goofazoid_SDS
I want to remove everything before the last name, and after my first go around with a script a few weeks ago I had the next class add !! before there last name:
Student Data sheet_steve.e.goofazoid_attempt_2019-05-21-19-39-49_!!goofazoid_SDS
with the thought that have a "marker" would make it easier to tell the script where to cut the name. Before that I tried removing from either end, but those require a # of characters to be removed and the file names have variable numbers of characters so that doesn't work. I then attempted to use a split with $_Basename and it did rename the file, but it cut out the portion of the name I wanted to save and stripped the ext from the file (even though I used + $_.Extension )
If this were just a one time thing I would suck it up and rename them manually but there are 20 forms they have to submit, for an average of 60 students/cycle and 10 cycles a year, so... that is not really an effective use of time.

TL/DR:
I need a powershell script that renames a file keeping everything to the right of a "marker" character (including extension) in a file name with the complication of the names having different numbers of characters because they contain students names and the date uploaded.


Thank you!

















*(because we have it at work and I don't have to convince the IT department that we need something else installed)
 

ComradeXavier

Ars Scholae Palatinae
881
Subscriptor++
Seems like an application for regular expressions:

Code:
PS J:\temp> echo stuff > "Student Data sheet_steve.e.goofazoid_attempt_2019-05-21-19-39-49_!!goofazoid_SDS.pdf"
PS J:\temp> gci


    Directory: J:\temp


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----        5/31/2019  12:55 PM             16 Student Data sheet_steve.e.goofazoid_attempt_2019-
                                                 05-21-19-39-49_!!goofazoid_SDS.pdf


PS J:\temp> Get-ChildItem | Rename-Item -NewName { $_.name -replace "^.*!!", "" }
PS J:\temp> gci


    Directory: J:\temp


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----        5/31/2019  12:55 PM             16 goofazoid_SDS.pdf


PS J:\temp>