George Mason University Antonin Scalia Law School

PowerShell Script For Semester Batches

This is a script I’ve developed after relying on CMD for so long and needing to use PowerShell to quickly export file names in large .ZIP files.

Be sure to run as Administrator and make sure your execution policy is not restricted.

You can call the function whatever you like. Export-Csv converts objects into a series of strings. Read more here.

Function GetClassList([string]$path, [string]$outputFile) {
$list = Get-ChildItem $path -Recurse | where {!$_.PSIsContainer}
$list | Select-Object BaseName | Export-Csv $outputFile
GetClassList "C:\Users\T\Desktop\fall2018\batch5" "C:\Users\T\Desktop\fall2018\batch5\list1.txt"

First argument is the directory and the second is your file destination.