Deleting cabinet files
===

I'm trying to create a script to delete cabinet files in virtual servers. For some reason, the code that I've created ends up not deleting any cabinet files and instead tries to delete the entire WINDOWS Directory, and I have no idea why this is occurring. Was curious if anyone might have any ideas on what the issue may be, since I can't find anything:


    $dir = "\\$server" + '\C$\windows'
    
    $cabinetArray = @()
    foreach ($item in get-childitem -path $dir){
    	if ($item.name -like "*.cab"){
    		$cabinetArray = $cabinetArray + $item
    		}
    	}
    
    for ($i = 0; $i -le $cabinetArray.length; $i++){
    	$removal = $dir + "\" + $cabinetArray[$i]
    	remove-item $removal -force -recurse 
    	}

I did some testing and it seems that for some reason my array that I'm trying to use to gather all the cabinet files isn't even getting filled for some reason. I'm not sure if there's a specific way to only gather the .cab files since right now whenever I run this on my test server it tries deleting everything.