Commands › SharePoint Online

New-SPOContainerTenantApplyFileVersionPolicyJob

SharePoint Online Microsoft.Online.SharePoint.PowerShell New-*

Queues a job to apply a file version policy across all containers of a SharePoint Embedded (SPE) container type. SharePoint Advanced Management license or Copilot license is required to run this cmdlet. > [!NOTE] > This feature is currently in preview and may not be available in your tenant.

Quick start script

# New-SPOContainerTenantApplyFileVersionPolicyJob — quick start (serv365.ai)
# 1. Connect (app-only shown; interactive: omit the certificate parameters)
Connect-SPOService -Url https://$org-admin.sharepoint.com

# 2. Capture the current state first — you cannot roll back what you never recorded
$before = Get-SPOContainerTenantApplyFileVersionPolicyJob
$before | Format-List

# 3. Make the change (dry run first)
New-SPOContainerTenantApplyFileVersionPolicyJob -ContainerTypeId <Guid> -CollectVersionData <SwitchParameter> -VersionPolicy <SPOFileVersionPolicySettings> -WhatIf
New-SPOContainerTenantApplyFileVersionPolicyJob -ContainerTypeId <Guid> -CollectVersionData <SwitchParameter> -VersionPolicy <SPOFileVersionPolicySettings>

# 4. Verify and diff
$after = Get-SPOContainerTenantApplyFileVersionPolicyJob
Compare-Object ($before | Out-String) ($after | Out-String)

Syntax — 3 parameter sets

WithExistingVersionPolicy (Default)

New-SPOContainerTenantApplyFileVersionPolicyJob -ContainerTypeId <Guid> [-TrimVersions] [-SetVersionPolicy]
 [-WhatIf] [-Confirm] [<CommonParameters>]

WithVersionPolicy

New-SPOContainerTenantApplyFileVersionPolicyJob -ContainerTypeId <Guid> [-TrimVersions]
 -VersionPolicy <SPOFileVersionPolicySettings> [-WhatIf] [-Confirm] [<CommonParameters>]

CollectData

New-SPOContainerTenantApplyFileVersionPolicyJob -ContainerTypeId <Guid> [-CollectVersionData]
 [-WhatIf] [-Confirm] [<CommonParameters>]

Parameters (7)

ParameterTypeRequiredWhat it controls
-ContainerTypeId Guid yes The ID of the SharePoint Embedded container type to which the job applies.
-Confirm SwitchParameter Prompts you for confirmation before running the cmdlet.
-SetVersionPolicy SwitchParameter Sets version policy for existing containers of the container type based on the container-type file version policy. The version policy applies to new versions created in these existing containers. Cannot be combined...
-CollectVersionData SwitchParameter yes Collects version data across all containers of the container type for use with `Get-SPOContainerTenantApplyFileVersionPolicyJobImpact`. Use this switch to run a data-collection pass before deciding whether and how to...
-TrimVersions SwitchParameter Trims existing versions for files in containers of the container type based on the container-type file version policy.
-VersionPolicy SPOFileVersionPolicySettings yes The version policy to apply to the container type before starting the job. When specified, the container-type version policy is updated and propagated to its containers. Optionally combine with `-TrimVersions` to...
-WhatIf SwitchParameter Shows what would happen if the cmdlet runs. The cmdlet is not run.

Reference facts derived from Microsoft documentation, © Microsoft, licensed CC BY 4.0; restructured with original guidance by serv365.ai.