Skip to content

Commit 8ae76ce

Browse files
authored
Create manage-user-sharing-expiration (SharePoint#5533)
* Create manage-user-sharing-expiration * Update to PowerShell for PNP * Update manage-user-sharing-expiration - Removed locale from URL - Removed extra heading - Removed extra white spaces * Update manage-user-sharing-expiration
1 parent af08895 commit 8ae76ce

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
title: Manage per user expiration for existing users on a site
3+
description: Explains how using client side object model to change a users expiration date for sharing links
4+
ms.date: 04/01/2020
5+
ms.prod: sharepoint
6+
localization_priority: Normal
7+
---
8+
9+
# Manage per user expiration for existing users on a site
10+
11+
If you are a site administrator, you may need to [manage expiring access](https://https://support.office.com/article/manage-guest-expiration-for-a-site) for users that have access to content on your site. If your administrator has set an expiration time for access, each guest that you invite to the site or with whom you share individual files and folders will be given access for a certain number of days. If you want them to continue to have access, you must extend their access on a regular basis. There also may be times you want to change an exisiting users expiration time and that can be done via the below method.
12+
13+
## Change expiration time for existing user
14+
15+
You can change expiration time for existing user using client side object model:
16+
17+
```powershell
18+
## DISCLAIMER:
19+
## Copyright (c) Microsoft Corporation. All rights reserved. This
20+
## script is made available to you without any express, implied or
21+
## statutory warranty, not even the implied warranty of
22+
## merchantability or fitness for a particular purpose, or the
23+
## warranty of title or non-infringement. The entire risk of the
24+
## use or the results from the use of this script remains with you.
25+
26+
param(
27+
[Parameter(Mandatory = $true)]
28+
[string] $SiteUrl,
29+
30+
[Parameter(Mandatory = $true)]
31+
[string] $UserEmail,
32+
33+
[Parameter(Mandatory = $true)]
34+
[int] $DaysToExpiration
35+
)
36+
37+
38+
#Connect to PNP
39+
Connect-PnPOnline -Url $SiteUrl
40+
41+
#ctx to the site
42+
$ctx = Get-PnPContext
43+
44+
#Get the User and check current expiration
45+
$user = Get-PnPUser | ? Email -eq $UserEmail
46+
$ctx.Load($user)
47+
$ctx.ExecuteQuery()
48+
49+
Write-Host "Current Expiration: $($user.Expiration)"
50+
51+
#Update Expiration for the user
52+
$user.Expiration = [DateTime]::UtcNow.AddDays($DaysToExpiration).ToString("yyyy-MM-ddTHH:mm:ssZ")
53+
$user.Update()
54+
$ctx.ExecuteQuery()
55+
56+
#Check new user Expiration for the user
57+
$ctx.Load($user)
58+
$ctx.ExecuteQuery()
59+
60+
Write-Host "New Expiration: $($user.Expiration)"
61+
```
62+

0 commit comments

Comments
 (0)