Configure Retention Policy Script for SharePoint Server UCC Libraries

Note

Library Retention Policies for SharePoint Online can be configured and executed using native SharePoint Online Information Management Policies (IMP) or using Microsoft Power Automate included in your Microsoft 365 subscription.

For Power Automate examples see Using Microsoft Power Automate with AnywhereNow

Configure the AnywhereNow Retention Policy Script as server scheduled task

Note

These steps are for SharePoint Server only using the authentication methods mentioned below.

Important

Find your site collection URL and Client Secret code. If you lost your Client Secret code, you can generate one by following “(Optional) Generate a new client secret”

  1. Grab the site collection URL (parent site of your ucc) and client secret

    Example: http://contoso.sharepointserver.com/sites/ucc/sub_site/ucc_support/uccconfigtemplate (only use bold part)

    Note

    This is also the site for the Creator.

  2. Copy the contents of the retention policy scripts to e.g. <drive>\program files\anywhere365\scripts\SPO_RetentionPolicy on the UCC server.

    Note

    The retention policy scrips can be requested at the support-desk.

  3. In the config file (RetentionPolicy.config), fill in the Targets:

    Same Site = For all sites on the root level:

    XML
    <Target enabled="true" type="SameLevel">https://contoso.sharepointserver.com/sites/ucc</Target>

    Site Collection = For all sites in this site collection:

    XML
    <Target enabled="true" type="SiteCollection">https://contoso.sharepointserver.com/sites/ucc</Target>

    Site = Only for this site:

    XML
    <Target enabled="true" type="Site">https://contoso.sharepointserver.com/sites/ucc</Target>
  4. Next step is to configure user authentication.

    1. For SharePoint Server (On-premises) Fill in the Username and Encrypted Password.

      Note

      Encrypt with the AnywhereNow password tool.

      XML
      <Username></Username>
      <Password></Password>
  5. Create a Windows Scheduled Task that runs indefinitely every day and starts the executable (WSP.A365.SharePoint.WebJob.RetentionPolicy.exe).

    Or use the example XML below to import it into Task Scheduler:

    XML
    <?xml version="1.0" encoding="UTF-16"?>
    <Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
    <RegistrationInfo>
    <Date>2019-04-16T15:24:40.1269215</Date>
    <Author>AnywhereNow</Author>
    </RegistrationInfo>
    <Triggers>
    <CalendarTrigger>
    <Repetition>
    <Interval>PT5M</Interval>
    <StopAtDurationEnd>false</StopAtDurationEnd>
    </Repetition>
    <StartBoundary>2018-01-09T10:35:00</StartBoundary>
    <Enabled>true</Enabled>
    <ScheduleByDay>
    <DaysInterval>1</DaysInterval>
    </ScheduleByDay>
    </CalendarTrigger>
    </Triggers>
    <Principals>
    <Principal id="Author">
    <UserId>S-1-5-21-3347327956-105208351-3318644539-10774</UserId>
    <LogonType>Password</LogonType>
    <RunLevel>LeastPrivilege</RunLevel>
    </Principal>
    </Principals>
    <Settings>
    <MultipleInstancesPolicy>Parallel</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
    <AllowHardTerminate>true</AllowHardTerminate>
    <StartWhenAvailable>false</StartWhenAvailable>
    <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
    <IdleSettings>
    <StopOnIdleEnd>true</StopOnIdleEnd>
    <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <AllowStartOnDemand>true</AllowStartOnDemand>
    <Enabled>true</Enabled>
    <Hidden>false</Hidden>
    <RunOnlyIfIdle>false</RunOnlyIfIdle>
    <WakeToRun>false</WakeToRun>
    <ExecutionTimeLimit>P3D</ExecutionTimeLimit>
    <Priority>7</Priority>
    </Settings>
    <Actions Context="Author">
    <Exec>
    <Command>"C:\Program Files\Anywhere365\Scripts\SPO_RetentionPolicy\WSP.A365.SharePoint.WebJob.RetentionPolicy.exe"</Command>
    </Exec>
    </Actions>
    </Task>
  6. Make sure that the account that performs the task has sufficient permissions to run the job, even if it is not logged in. Run with highest privileges.