Looping through folder locations (noob query)

I’m using the following code to unzip files in the ‘current directory’. However, I’d like to loop through a list of folder locations and run this code at each location. Any any advice would be welcome.

$dir = dir *.zip
foreach($item in $dir)
        Expand-Archive -Path $item -DestinationPath ($item -replace '.zip','') -Force


Welcome to the forum. :wave:t4:

You should not use aliasses in scripts or in forums like this. Here you can read more about this topic:

If you want to get all ZIP files in all subdirectories you can advice Get-ChildItem to recurse down the directory tree with the parameter -Recurse

$ZipFileList = Get-ChildItem -Path .\ -Filter *.zip -Recurse
foreach ($ZipFile in $ZipFileList) {
    Expand-Archive -Path $ZipFile -DestinationPath ($ZipFile -replace '.zip', '') -Force