You correctly referenced $_.displayname for -Name but later incorrectly use $displayname. Also, sometimes displayname can have characters present that are not allowed in a filename. You may want to reconsider and use ID instead. You also don’t need the select displayname, it isn’t adding anything.