Need Help with Setting Media Expiration Policies in SharePoint Online Using PowerShell

0
4
Asked By CuriousCoder92 On

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

Answered By TechieTim123 On

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!

FileGuru92 -

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

DataDiva77 -

Thanks for the tip! I’ll implement that and see if it works.

Answered By PowershellPro42 On

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!

SyntaxSleuth -

I think the brackets just got missed during pasting! Just double-check that.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.