Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
## [Current nightly]

### Added
- Added `Get-PnPSiteContentMoveState` cmdlet to retrieve SharePoint Online site content move states.
Comment thread
gautamdsheth marked this conversation as resolved.
Outdated
- Added `Get-PnPUnifiedGroupMoveState` cmdlet to retrieve SharePoint Online Microsoft 365 group move states. [#5362](https://github.com/pnp/powershell/pull/5362)
- Added `Start-PnPUserAndContentMove` cmdlet to start SharePoint Online multi-geo user and OneDrive content move jobs. [#5355](https://github.com/pnp/powershell/pull/5355)
- Added `Get-PnPUserAndContentMoveState` cmdlet to retrieve SharePoint Online user and OneDrive content move states.
Expand Down
197 changes: 197 additions & 0 deletions documentation/Get-PnPSiteContentMoveState.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
---
Module Name: PnP.PowerShell
title: Get-PnPSiteContentMoveState
schema: 2.0.0
applicable: SharePoint Online
external help file: PnP.PowerShell.dll-Help.xml
online version: https://pnp.github.io/powershell/cmdlets/Get-PnPSiteContentMoveState.html
---

# Get-PnPSiteContentMoveState

## SYNOPSIS
Returns the state of SharePoint Online site content move jobs.

## SYNTAX

### MoveReport

```powershell
Get-PnPSiteContentMoveState [-Limit <UInt32>] [-MoveStartTime <DateTime>] [-MoveEndTime <DateTime>] [-MoveState <MoveState>] [-MoveDirection <MoveDirection>] [-Connection <PnPConnection>]
```

### SourceSiteUrl

```powershell
Get-PnPSiteContentMoveState -SourceSiteUrl <String> [-Connection <PnPConnection>]
```

### SiteMoveId

```powershell
Get-PnPSiteContentMoveState -SiteMoveId <Guid> [-Connection <PnPConnection>]
```

## DESCRIPTION
Returns status information for SharePoint Online multi-geo site content move jobs. You can retrieve one move job by source site URL or site move ID, or retrieve a move report filtered by state, direction, time window, and limit. When no move state or direction is specified, all states and directions are returned.

## EXAMPLES

### EXAMPLE 1

```powershell
Get-PnPSiteContentMoveState -SourceSiteUrl https://contoso.sharepoint.com/sites/project
```

Returns the move state for the specified source site.

### EXAMPLE 2

```powershell
Get-PnPSiteContentMoveState -SiteMoveId 8f6f8e3a-2c1f-4d5b-9a7e-6b3c2a1f0e9d
```

Returns the move state for the specified site move job ID.

### EXAMPLE 3

```powershell
Get-PnPSiteContentMoveState -MoveState All -MoveDirection All -Limit 100
```

Returns up to 100 site content move jobs regardless of state or direction.

### EXAMPLE 4

```powershell
Get-PnPSiteContentMoveState -MoveStartTime (Get-Date).AddDays(-7) -MoveEndTime (Get-Date) -MoveState Failed -MoveDirection MoveOut -Verbose
```

Returns failed site move-out jobs from the last seven days and includes additional diagnostic properties.

## PARAMETERS

### -Connection
Optional connection to be used by the cmdlet. Retrieve the value for this parameter by specifying `-ReturnConnection` on `Connect-PnPOnline` or by executing `Get-PnPConnection`.

```yaml
Type: PnPConnection
Parameter Sets: (All)

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Limit
Limits the number of move report entries returned. The value must be between 1 and 1000.

```yaml
Type: UInt32
Parameter Sets: MoveReport

Required: False
Position: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False
```

### -MoveDirection
Filters move report entries by move direction. Valid values are `MoveOut`, `MoveIn`, and `All`.

```yaml
Type: MoveDirection
Parameter Sets: MoveReport

Required: False
Position: Named
Default value: All
Accept pipeline input: False
Accept wildcard characters: False
```

### -MoveEndTime
Filters move report entries to moves ending at or before the specified date and time. The value is converted to UTC before it is sent to SharePoint Online.

```yaml
Type: DateTime
Parameter Sets: MoveReport

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -MoveStartTime
Filters move report entries to moves starting at or after the specified date and time. The value is converted to UTC before it is sent to SharePoint Online.

```yaml
Type: DateTime
Parameter Sets: MoveReport

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -MoveState
Filters move report entries by move state. Valid values are `NotStarted`, `InProgress`, `Success`, `Failed`, `Stopped`, `Queued`, `NotSupported`, `Rescheduled`, and `All`.

```yaml
Type: MoveState
Parameter Sets: MoveReport

Required: False
Position: Named
Default value: All
Accept pipeline input: False
Accept wildcard characters: False
```

### -SiteMoveId
The site move job ID whose state should be retrieved.

```yaml
Type: Guid
Parameter Sets: SiteMoveId

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -SourceSiteUrl
The source URL of the site collection whose move state should be retrieved.

```yaml
Type: String
Parameter Sets: SourceSiteUrl

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

## OUTPUTS

### System.Management.Automation.PSObject
Returns objects with `SourceSiteUrl`, `TargetSiteUrl`, `MoveJobId`, `SourceDataLocation`, `DestinationDataLocation`, `TimeStamp`, and `MoveState` properties. Validation-only move jobs return `ValidationState` instead of `TimeStamp` and `MoveState`. When `-Verbose` is specified, additional move job details are returned.

## RELATED LINKS

[Get-PnPUserAndContentMoveState](Get-PnPUserAndContentMoveState.md)

[Get-PnPUnifiedGroupMoveState](Get-PnPUnifiedGroupMoveState.md)

[Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp)
85 changes: 85 additions & 0 deletions src/Commands/Admin/GetSiteContentMoveState.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
using PnP.PowerShell.Commands.Attributes;
using PnP.PowerShell.Commands.Base;
using PnP.PowerShell.Commands.Model;
using PnP.PowerShell.Commands.Utilities.MultiGeo;
using System;
using System.Linq;
using System.Management.Automation;

namespace PnP.PowerShell.Commands.Admin
{
[Cmdlet(VerbsCommon.Get, "PnPSiteContentMoveState", DefaultParameterSetName = ParameterSetMoveReport)]
[RequiredApiApplicationPermissions("sharepoint/Sites.FullControl.All")]
[RequiredApiDelegatedPermissions("sharepoint/AllSites.FullControl")]
[OutputType(typeof(PSObject))]
public class GetSiteContentMoveState : PnPSharePointOnlineAdminCmdlet
{
private const string ParameterSetMoveReport = "MoveReport";
private const string ParameterSetSourceSiteUrl = "SourceSiteUrl";
private const string ParameterSetSiteMoveId = "SiteMoveId";

[Parameter(Mandatory = true, ParameterSetName = ParameterSetSourceSiteUrl)]
[ValidateNotNullOrEmpty]
public string SourceSiteUrl { get; set; }

[Parameter(Mandatory = true, ParameterSetName = ParameterSetSiteMoveId)]
[ValidateNotNullOrEmpty]
public Guid SiteMoveId { get; set; }

[Parameter(Mandatory = false, ParameterSetName = ParameterSetMoveReport)]
[ValidateRange(1, 1000)]
public uint Limit { get; set; }

[Parameter(Mandatory = false, ParameterSetName = ParameterSetMoveReport)]
public DateTime MoveStartTime { get; set; }

[Parameter(Mandatory = false, ParameterSetName = ParameterSetMoveReport)]
public DateTime MoveEndTime { get; set; }

[Parameter(Mandatory = false, ParameterSetName = ParameterSetMoveReport)]
public MoveState MoveState { get; set; } = MoveState.All;

[Parameter(Mandatory = false, ParameterSetName = ParameterSetMoveReport)]
public MoveDirection MoveDirection { get; set; } = MoveDirection.All;

protected override void ExecuteCmdlet()
{
var multiGeoRestApiClient = new MultiGeoRestApiClient(AdminContext);
var includeVerboseProperties = IsVerboseMode();

if (ParameterSetName == ParameterSetSourceSiteUrl)
{
WriteMoveState(multiGeoRestApiClient.GetSiteMoveJob(SourceSiteUrl), includeVerboseProperties);
return;
}

if (ParameterSetName == ParameterSetSiteMoveId)
{
WriteMoveState(multiGeoRestApiClient.GetSiteMoveJob(SiteMoveId), includeVerboseProperties);
return;
}

var moveStartTimeInUtc = MoveStartTime == DateTime.MinValue ? DateTime.MinValue : MoveStartTime.ToUniversalTime();
var moveEndTimeInUtc = MoveEndTime == DateTime.MinValue ? DateTime.MinValue : MoveEndTime.ToUniversalTime();
var moveStates = multiGeoRestApiClient.GetSiteMoveJobs(MoveState, MoveDirection, moveStartTimeInUtc, moveEndTimeInUtc, Limit)
.Where(moveState => moveState != null)
.OrderByDescending(moveState => moveState.LastModified)
.Select(moveState => UserAndContentMoveStateFormatter.ConvertSiteMoveStateToPSObject(moveState, includeVerboseProperties));

WriteObject(moveStates, true);
}

private void WriteMoveState(SiteMoveJob moveState, bool includeVerboseProperties)
{
if (moveState != null)
{
WriteObject(UserAndContentMoveStateFormatter.ConvertSiteMoveStateToPSObject(moveState, includeVerboseProperties));
}
}

private bool IsVerboseMode()
{
return MyInvocation.BoundParameters.TryGetValue("Verbose", out var verboseValue) && verboseValue is SwitchParameter verbose && verbose.ToBool();
}
}
}
95 changes: 95 additions & 0 deletions src/Commands/Model/SiteMoveJob.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
using System;
using System.Text.Json.Serialization;

namespace PnP.PowerShell.Commands.Model
{
/// <summary>
/// Contains the state of a SharePoint Online site content move job.
/// </summary>
public class SiteMoveJob
{
public string ApiVersion { get; set; }

public Guid Id { get; set; }

[JsonConverter(typeof(JsonStringEnumConverter))]
public MoveOption Option { get; set; }

public string Reserve { get; set; }

[JsonConverter(typeof(JsonStringEnumConverter))]
public JobSubType SubType { get; set; }

[JsonConverter(typeof(JsonStringEnumConverter))]
public JobType Type { get; set; }

public Guid BatchId { get; set; }

public string CancelTriggeredBy { get; set; }

public string DestinationDataLocation { get; set; }

[JsonConverter(typeof(JsonStringEnumConverter))]
public MoveDirection Direction { get; set; }

public string ErrorMessage { get; set; }

public DateTime FinishedDateInUtc { get; set; }

public bool IsReadOnlyAlertRaised { get; set; }

[JsonConverter(typeof(JsonStringEnumConverter))]
public MoveJobPhase JobPhase { get; set; }

public string Notify { get; set; }

public DateTime PreferredMoveBeginDateInUtc { get; set; }

public DateTime PreferredMoveEndDateInUtc { get; set; }

public Guid SiteId { get; set; }

public string SourceDataLocation { get; set; }

[JsonConverter(typeof(JsonStringEnumConverter))]
public MoveState State { get; set; }

public string TriggeredBy { get; set; }

public bool EnableRestoreOnSiteToMove { get; set; }

public bool EnableSiteToMoveDatastore { get; set; }

public Guid SourceCompanyId { get; set; }

public Guid SourceInstanceId { get; set; }

public string SourceMySiteHostUrl { get; set; }

public Guid SourceSiteSubscriptionId { get; set; }

public string SourceSiteUrl { get; set; }

public Guid TargetCompanyId { get; set; }

public string TargetFarmId { get; set; }

public Guid TargetInstanceId { get; set; }

public Guid TargetSiteSubscriptionId { get; set; }

public string TargetSiteUrl { get; set; }

public string TenantMergeSourceMySiteHostUrl { get; set; }

public string TenantMergeTargetMySiteHostUrl { get; set; }

public bool IsContentMoved { get; set; }

public DateTime LastModified { get; set; }

public DateTime StartedDateInUtc { get; set; }

public string StateName { get; set; }
}
}
Loading
Loading