Need help with SharePoint Online Cmdlets

Anonymous
2025-01-28T20:43:10+00:00

I am trying to set version limits, expiration and trim versions to clean up space on some sites. When trying to run the cmdlets I am getting errors saying they are not recognized.

  • New-SPOSiteFileVersionExpirationReportJob
  • Set-SPOListVersionPolicy
  • New-SPOListFileVersionBatchDeleteJob

Set-PnPList -Identity "Demo List" -EnableAutoExpirationVersionTrim $false -ExpireVersionsAfterDays 30 -MajorVersions 500

Both these parameters are not recognized on the PnP -EnableAutoExpirationVersionTrim $false  -ExpireVersionsAfterDays 30

I have

  • Management Shell version 16.0.25715.12000
  • PowerShell 7.6
  • PnP 3.29.2101

Run as admin and also SP Admin Role.

Are these deprecated or am I missing something?

Microsoft 365 and Office | SharePoint | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Anonymous
    2025-01-29T08:08:26+00:00

    Dear Admin,

    Good day!! I hope you are doing well~

    As per the description shared, I understand your concern and I would like to convey that I have tested the behavior at my end where the New-SPOSiteFileVersion and New-SPOListFileVersion are present in the latest SharePoint Online PowerShell module:

    So, I request you check whether you are using the latest SharePoint Online PowerShell module:

    Step 1: Open the Windows PowerShell ISE as an administrator> Run the following command Update-Module -Name Microsoft.Online.SharePoint.PowerShell

    Step 2: Now enter Get-Help ‘New-Spolist’ -ShowWindow and see whether you get New-SPOListFileVersion

    Step 3: Now enter Get-Help ‘New-SpositeF’ -ShowWindow and see whether you get New-SPOSiteFileVersion

    If yes, then you can follow the following articles:

    New-SPOSiteFileVersionBatchDeleteJob (Microsoft.Online.SharePoint.PowerShell) | Microsoft Learn

    New-SPOSiteFileVersionExpirationReportJob (Microsoft.Online.SharePoint.PowerShell) | Microsoft Learn

    For enabling site version limits or library version limits, please refer to the commands in the following articles:

    Site Version Limits: Change version history limits for a Site - SharePoint in Microsoft 365 | Microsoft Learn

    Library Version Limits: Set version limits for a document library - SharePoint in Microsoft 365 | Microsoft Learn

    If you still encounter the error, can you please share the following information which will help us to better understand and guide you further:

    1. Screenshot of the error message encountered when running the command mentioned in the articles.
    2. SharePoint Online PowerShell Module version. Open your PowerShell as an administrator> Run the command Get-Module -Name Microsoft.Online.SharePoint.PowerShell -ListAvailable | Select Name,Version > Take the screenshot of the output and share it with us.

    Our sincere apologies for not resolving the problem in the first reply but answers to the above queries will help us to better understand your situation and guide you in the right direction.

    Appreciate your patience and understanding. Have a great day!!

    Best Regards,

    Sophia

    0 comments No comments
  2. Anonymous
    2025-01-29T14:52:39+00:00

    I ran the requested items and still have the issue.

    0 comments No comments
  3. Anonymous
    2025-01-29T16:23:03+00:00

    I believe I am good now. I removed all other versions from the machine and then ran the provided commands. Seems it was a conflict with versions.

    0 comments No comments
  4. Anonymous
    2025-01-30T03:00:48+00:00

    Dear Admin,

    Glad to hear the problem has been resolved after updating the SharePoint Online PowerShell Module and removing old version modules.

    Here is the summary of the issue:

    Issue:

    New-SPOListFileVersion... & New-SPOSiteFileVersion... commands are not being recognised in the PowerShell.

    Environment:

    Windows PowerShell, SharePoint Online Module.

    Solution:

    Please uninstall the previous version of the SharePoint Online Modules and install the latest version of the SharePoint Online Module to get all latest released SharePoint Online commands.

    If you feel we have tried our best to help you, I would like to request you provide the feedback on this summary reply by adding your valuable vote:

    Also other users will also search information in this community. Your valuable vote will definitely also help other users who have similar queries easily to find useful information more quickly.

    Greatly Appreciate again for your patience and understanding.

    I wish you keep safe and Hope you have a great year as well😊!

    Sincerely,

    Sophia

    1 person found this answer helpful.
    0 comments No comments