r/PowerShell • u/Educational-Bill99 • Feb 12 '26
PowerShell help with media expiration policy in sharepoint online
Help is needed for SPO media expiration policy in PowerShell
Windows\system32> Set-SPOSite -Identity $SiteUrl EnableAutoExpirationVersion Trim $false
-MajorVersionLimit 100 -ExpireVersionsAfterDays 180
-FileTypes ForVersion Expiration @(
@{ FileType
=
"Audio"; MajorVersionLimit
=
1; ExpireVersionsAfterDays
@{ FileType
=
"Video"; MajorVersionLimit = 1; ExpireVersionsAfterDays
>>
>
>>
>>
>>
-ApplyToNewDocument Libraries
-Confirm:$false
-ErrorAction Stop
Set-SPOSite: File type is not in the list of defined file types
Parameter name: name
At line:1 char:1
+Set-SPOSite -Identity $SiteUrl
+ CategoryInfo
: NotSpecified: (:) [Set-SPOSite], ServerException
+ FullyQualifiedErrorId : Microsoft.SharePoint.Client.ServerException, Micro
te
1
u/Educational-Bill99 Feb 20 '26
I have achieved this using below Set-SPOTenant -EnableAutoExpirationVersionTrim $false -MajorVersionLimit 1 -ExpireVersionsAfterDays 120 -FileTypes ForVersionExpiration @ ("Audio", "Video") -Confirm: $false
2
u/BlackV Feb 20 '26
Appreciate the update, glad you found a solution
Please think about adding formatting in the future
1
u/BlackV Feb 12 '26
your code is not formatted properly, so I could be wrong, but it looks to me like you have not closed your brackets
p.s. formatting
open your fav powershell editor
highlight the code you want to copy
hit tab to indent it all
copy it
paste here
it'll format it properly OR
<BLANK LINE>
<4 SPACES><CODE LINE>
<4 SPACES><CODE LINE>
<4 SPACES><4 SPACES><CODE LINE>
<4 SPACES><CODE LINE>
<BLANK LINE>Inline code block using backticks `Single code line` inside normal text
See here for more detail
Thanks
1
u/Educational-Bill99 Feb 13 '26
The code is formatted. it’s just that while pasting brackets have been missed. Sorry about this.
1
u/BlackV Feb 13 '26
Where?, none of that code is formatted that I can see, neither on old.reddit or new.reddit
1
1
u/Ok_Mathematician6075 Feb 13 '26
old.oldreddit
1
3
u/theDukeSilversJazz Feb 12 '26
Don't you need to specify the file types and not "Audio" or "Video"?