I don’t have anything using CSV to test this with but reading the docs it seems to just pass the command off to defrag.exe, is that correct? If so, do you just get back the output from defrag.exe? Something like this should work:
[int]$fragmentation = (((defrag f: /A | Select-String 'Total fragmented space') -split '=') -replace '%','').trim()
Select-String gets the relevant line from the output. We split that on the equals sign which gives us a collection containing two strings ‘Total fragmented space’ and ‘n%’. We remove the % sign by replacing it with nothing and then trim the leading space. We then choose the second string from the collection (which has the index 1).