Home

PowerShell script to unlock documents in SharePoint Online

%3CLINGO-SUB%20id%3D%22lingo-sub-1094959%22%20slang%3D%22en-US%22%3EPowerShell%20script%20to%20unlock%20documents%20in%20SharePoint%20Online%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1094959%22%20slang%3D%22en-US%22%3E%3CDIV%3E%3CFONT%3EHi%2C%3CBR%20%2F%3EI've%20a%20DocumentLibrary%20in%20which%20documents%20are%20required%20to%20be%20checked%20out%20but%20when%20I%20create%20a%20new%20document%2C%20as%20Admin%2C%20I%20can't%20to%20check%20it%20in%20because%20required%20fields%20are%20empty%20and%2C%20at%20the%20same%20time%2C%20I%20can't%20edit%20them%20because%20there%20is%20a%20lock%20created%20by%20myself.%3C%2FFONT%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CFONT%3EI've%20read%20I%20can't%20do%20anything%20by%20UI%20and%20I%20should%20wait%20untill%2010%20minutes%20before%20to%20proceed%20saving%20properties%2C%20someone%20says%20it%20can%20take%20more%20than%2010%20minutes%20but%2C%20anyway%2C%20I%20can't%20wait%20neither%2010%20minutes%3A%20I%20would%20like%20to%20write%20a%20powershell%20script%20to%20launch%20every%20time%20I%20need%20to%20unlock%20my%20documents%20but%20I%20can't%20find%20something%20that%20could%20work%20with%20SharePoint%20Online%20(only%20for%20SharePoint%20Server)%3A%20any%20advice%3F%3C%2FFONT%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CFONT%3EThanks%20in%20advance.%3C%2FFONT%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1094959%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDocument%20Library%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESharePoint%20Online%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1095420%22%20slang%3D%22en-US%22%3ERe%3A%20PowerShell%20script%20to%20unlock%20documents%20in%20SharePoint%20Online%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1095420%22%20slang%3D%22en-US%22%3E%3CP%3EHello%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F509264%22%20target%3D%22_blank%22%3E%40emalac%3C%2FA%3E%26nbsp%3B!%26nbsp%3B%3CBR%20%2F%3EYou%20could%20try%20and%20use%20the%20PNP%20mdule%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%23Variables%3C%2FP%3E%3CP%3E%24Cred%20%3D%20Get-Credential%3C%2FP%3E%3CP%3E%24SiteURL%20%3D%20%22%3CA%20href%3D%22https%3A%2F%2Fdomain.sharepoint.com%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdomain.sharepoint.com%3C%2FA%3E%22%3C%2FP%3E%3CP%3E%24FileLocation%20%3D%22%2FDocuments%2FFile.docx%22%3C%2FP%3E%3CP%20class%3D%22line%20number4%20index3%20alt1%22%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%23Connect%20to%20PNP%20Online%3C%2FP%3E%3CP%3EConnect-PnPOnline%20-Url%20%24SiteURL%20-Credentials%26nbsp%3B%24Cred%3C%2FP%3E%3CP%20class%3D%22line%20number7%20index6%20alt2%22%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%23Check%20In%20a%20File%3C%2FP%3E%3CP%3ESet-PnPFileCheckedIn%20-Url%20%24FileLocation-CheckinType%20MajorCheckIn%20-Comment%20%22Checked%20In%20at%20%24(Get-Date)%22%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
emalac
Visitor
Hi,
I've a DocumentLibrary in which documents are required to be checked out but when I create a new document, as Admin, I can't to check it in because required fields are empty and, at the same time, I can't edit them because there is a lock created by myself.
 
I've read I can't do anything by UI and I should wait untill 10 minutes before to proceed saving properties, someone says it can take more than 10 minutes but, anyway, I can't wait neither 10 minutes: I would like to write a powershell script to launch every time I need to unlock my documents but I can't find something that could work with SharePoint Online (only for SharePoint Server): any advice?
 
Thanks in advance.
1 Reply

Hello@emalac ! 
You could try and use the PNP mdule 

 

#Variables

$Cred = Get-Credential

$SiteURL = "https://domain.sharepoint.com"

$FileLocation ="/Documents/File.docx"

 

#Connect to PNP Online

Connect-PnPOnline -Url $SiteURL -Credentials $Cred

 

#Check In a File

Set-PnPFileCheckedIn -Url $FileLocation-CheckinType MajorCheckIn -Comment "Checked In at $(Get-Date)"

Related Conversations
Make Share function in Edge more useful
HotCakeX in Discussions on
2 Replies
API access to the new Project Online
BenjaminMel in Project on
2 Replies
Issue when accessing enterprise resource pool
cmill262 in Project on
4 Replies
Intune Scripting
jesusleon in Microsoft Intune on
2 Replies
Last Log In Activity on Microsoft Project?
Devryk in Project on
0 Replies