Events
Microsoft 365 Community Conference
May 6, 2 PM - May 9, 12 AM
Skill up for the era of AI at the ultimate community-led Microsoft 365 event, May 6-8 in Las Vegas.
Learn moreThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
If you are a site administrator, you may need to manage expiring access 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.
You can change expiration time for existing user using client side object model:
## DISCLAIMER:
## Copyright (c) Microsoft Corporation. All rights reserved. This
## script is made available to you without any express, implied or
## statutory warranty, not even the implied warranty of
## merchantability or fitness for a particular purpose, or the
## warranty of title or non-infringement. The entire risk of the
## use or the results from the use of this script remains with you.
param(
[Parameter(Mandatory = $true)]
[string] $SiteUrl,
[Parameter(Mandatory = $true)]
[string] $UserEmail,
[Parameter(Mandatory = $true)]
[int] $DaysToExpiration
)
#Connect to PNP
Connect-PnPOnline -Url $SiteUrl
#ctx to the site
$ctx = Get-PnPContext
#Get the User and check current expiration
$user = Get-PnPUser | ? Email -eq $UserEmail
$ctx.Load($user)
$ctx.ExecuteQuery()
Write-Host "Current Expiration: $($user.Expiration)"
#Update Expiration for the user
$user.Expiration = [DateTime]::UtcNow.AddDays($DaysToExpiration).ToString("yyyy-MM-ddTHH:mm:ssZ")
$user.Update()
$ctx.ExecuteQuery()
#Check new user Expiration for the user
$ctx.Load($user)
$ctx.ExecuteQuery()
Write-Host "New Expiration: $($user.Expiration)"
Events
Microsoft 365 Community Conference
May 6, 2 PM - May 9, 12 AM
Skill up for the era of AI at the ultimate community-led Microsoft 365 event, May 6-8 in Las Vegas.
Learn moreTraining
Module
Manage SharePoint Online by using Windows PowerShell - Training
Manage SharePoint Online by using Windows PowerShell
Certification
Microsoft 365 Certified: Administrator Expert - Certifications
If you’re an administrator who deploys and manages Microsoft 365 and performs Microsoft 365 tenant-level implementation and administration of cloud and hybrid environments, this certification is designed for you.