-
Notifications
You must be signed in to change notification settings - Fork 408
Add Get-PnPSiteContentMoveState #5365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.