-
Notifications
You must be signed in to change notification settings - Fork 360
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementation of Get-PnpFileCheckedOut
- Loading branch information
1 parent
8fccd8a
commit 3a92e92
Showing
6 changed files
with
181 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 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,66 @@ | ||
--- | ||
Module Name: PnP.PowerShell | ||
title: Get-PnPFileCheckedOut | ||
schema: 2.0.0 | ||
applicable: SharePoint Online | ||
external help file: PnP.PowerShell.dll-Help.xml | ||
online version: https://pnp.github.io/powershell/cmdlets/Get-PnPFileCheckedOut.html | ||
--- | ||
|
||
# Get-PnPFileCheckedOut | ||
|
||
## SYNOPSIS | ||
Returns all files that are currently checked out in a library | ||
|
||
## SYNTAX | ||
|
||
```powershell | ||
Get-PnPFileCheckedOut -List <ListPipeBind> [-Connection <PnPConnection>] | ||
``` | ||
|
||
## DESCRIPTION | ||
|
||
This cmdlet allows to retrieve all files that are currently checked out in a library. | ||
|
||
## EXAMPLES | ||
|
||
### EXAMPLE 1 | ||
```powershell | ||
Get-PnPFileCheckedOut -List "Documents" | ||
``` | ||
|
||
Returns all files that are currently checked out in the "Documents" library. | ||
|
||
## PARAMETERS | ||
|
||
### -Connection | ||
Optional connection to be used by the cmdlet. Retrieve the value for this parameter by either 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 | ||
``` | ||
### -List | ||
The list instance, list display name, list url or list id to query for checked out files | ||
```yaml | ||
Type: String | ||
Parameter Sets: (All) | ||
|
||
Required: True | ||
Position: 0 | ||
Default value: None | ||
Accept pipeline input: True (ByValue) | ||
Accept wildcard characters: False | ||
``` | ||
## RELATED LINKS | ||
[Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp) |
This file contains 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 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,37 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Management.Automation; | ||
using Microsoft.SharePoint.Client; | ||
using PnP.PowerShell.Commands.Base.PipeBinds; | ||
|
||
namespace PnP.PowerShell.Commands.Files | ||
{ | ||
[Cmdlet(VerbsCommon.Get, "PnPFileCheckedOut")] | ||
[OutputType(typeof(IEnumerable<Model.SharePoint.CheckedOutFile>))] | ||
public class GetFileCheckedOut : PnPWebCmdlet | ||
{ | ||
[Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true)] | ||
public ListPipeBind List; | ||
|
||
protected override void ExecuteCmdlet() | ||
{ | ||
var list = List.GetList(CurrentWeb); | ||
var checkedOutFiles = list.GetCheckedOutFiles(); | ||
|
||
ClientContext.Load(checkedOutFiles, cof => cof.Include(c => c.CheckedOutBy, c => c.ServerRelativePath)); | ||
ClientContext.ExecuteQueryRetry(); | ||
|
||
checkedOutFiles.Select(c => new Model.SharePoint.CheckedOutFile | ||
{ | ||
ServerRelativeUrl = c.ServerRelativePath.DecodedUrl, | ||
CheckedOutBy = new Model.User | ||
{ | ||
DisplayName = c.CheckedOutBy.Title, | ||
Email = c.CheckedOutBy.Email, | ||
Id = c.CheckedOutBy.Id, | ||
LoginName = c.CheckedOutBy.LoginName | ||
} | ||
}).ToList().ForEach(WriteObject); | ||
} | ||
} | ||
} |
This file contains 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,18 @@ | ||
namespace PnP.PowerShell.Commands.Model.SharePoint | ||
{ | ||
/// <summary> | ||
/// Contains the properties of a checked out file | ||
/// </summary> | ||
public class CheckedOutFile | ||
{ | ||
/// <summary> | ||
/// Server relative url to the checked out | ||
/// </summary> | ||
public string ServerRelativeUrl { get; set; } | ||
|
||
/// <summary> | ||
/// The user who has the file checked out | ||
/// </summary> | ||
public User CheckedOutBy { get; set; } | ||
} | ||
} |
This file contains 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,28 @@ | ||
namespace PnP.PowerShell.Commands.Model | ||
{ | ||
/// <summary> | ||
/// Contains information about a user | ||
/// </summary> | ||
public class User | ||
{ | ||
/// <summary> | ||
/// Unique identifier of the user in the user information list of the site collection | ||
/// </summary> | ||
public int? Id { get; set; } | ||
|
||
/// <summary> | ||
/// Display name of the user (a.k.a. Title) | ||
/// </summary> | ||
public string DisplayName { get; set; } | ||
|
||
/// <summary> | ||
/// The login name of the user | ||
/// </summary> | ||
public string LoginName { get; set; } | ||
|
||
/// <summary> | ||
/// The email address of the user | ||
/// </summary> | ||
public string Email { get; set; } | ||
} | ||
} |