I'm trying to set up an expiration policy for media files in SharePoint Online using PowerShell, but I'm running into issues. Here's the command I'm using:
`Set-SPOSite -Identity $SiteUrl -EnableAutoExpirationVersionTrim $false -MajorVersionLimit 100 -ExpireVersionsAfterDays 180 -FileTypesForVersionExpiration @( @{ FileType = "Audio"; MajorVersionLimit = 1; ExpireVersionsAfterDays = 180 }, @{ FileType = "Video"; MajorVersionLimit = 1; ExpireVersionsAfterDays = 180 } ) -ApplyToNewDocumentLibraries -Confirm:$false -ErrorAction Stop`
When I run it, I get the error: "File type is not in the list of defined file types". Can anyone help me troubleshoot this?
2 Answers
It looks like you're using general terms like "Audio" or "Video", but you need to specify the actual file types. Try updating your command to something like this:
`-FileTypesForVersionExpiration @( @{ FileType = "mp3"; MajorVersionLimit = 1; ExpireVersionsAfterDays = 180 }, @{ FileType = "wav"; MajorVersionLimit = 1; ExpireVersionsAfterDays = 180 }, @{ FileType = "mp4"; MajorVersionLimit = 1; ExpireVersionsAfterDays = 180 }, @{ FileType = "mov"; MajorVersionLimit = 1; ExpireVersionsAfterDays = 180 } )`
This should resolve your error!
Thanks for the tip! I’ll implement that and see if it works.
Your command seems to be improperly formatted. Make sure you've closed all your brackets correctly. Here's how you could format it:
- Open your favorite PowerShell editor,
- Highlight the code you want to copy,
- Hit tab to indent it all,
- Copy it and paste here.
This can help you catch any missing brackets easily!
I think the brackets just got missed during pasting! Just double-check that.

Double-check that against the official Microsoft documentation. They usually have examples that can help clarify what file types you should be using.