I cannot get Set-PnPFileCheckedIn to work

%3CLINGO-SUB%20id%3D%22lingo-sub-278051%22%20slang%3D%22en-US%22%3EI%20cannot%20get%20Set-PnPFileCheckedIn%20to%20work%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-278051%22%20slang%3D%22en-US%22%3E%3CP%3EHere%20is%20the%20part%20of%20the%20code%20that%20does%20the%20checkin%20for%20files%20in%20a%20folder%3C%2FP%3E%3CP%3E%24folder%20%3D%20%22%2FDocuments%22%26nbsp%3B%3C%2FP%3E%3CP%3E%24filesInFolder%20%3D%20Get-PnPFolderItem%20-FolderSiteRelativeUrl%20%24folder%20-ItemType%20File%3CBR%20%2F%3Eforeach(%24file%20in%20%24filesInFolder)%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20if(%24file.Level%20-eq%20%22Checkout%22)%20%7B%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%24filePath%20%3D%20(%24folder%20%2B%20%22%2F%22%20%2B%20%24file.Name)%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20Set-PnPFileCheckedIn%20-Url%20%24filePath%20-CheckinType%20MajorCheckIn%20-Comment%20%22Checked%20in%20by%20Script%22%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CP%3EI%20keep%20getting%20the%20error%3A%3C%2FP%3E%3CP%3ESet-PnpFileCheckedIn%20%3A%20serverRelativeUrl%3C%2FP%3E%3CP%3EParameter%20name%3A%20Specified%20value%20is%20not%20supported%20for%20the%20serverRelativeUrl%20parameter%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20tried%20every%20variation%20of%20the%20url%20I%20can%20think%20of%20%3A%3C%2FP%3E%3CP%3E%22%2FDocuments%2Ftest.txt%22%3C%2FP%3E%3CP%3E%22Documents%2Ftest.txt%22%3C%2FP%3E%3CP%3E%22%2Fsites%2Ftestsite%2FDocuments%2Ftest.txt%22%3C%2FP%3E%3CP%3Eetc...%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20need%20to%20check%20in%2060%2C000%20documents%20that%20a%20user%20uploaded%20checked%20out%20and%20nobody%20can%20see%20them.%20They%20are%20in%20multiple%20folders.%20I%20thought%20that%20this%20would%20be%20an%20easy%20fix%2C%20but%20I%20have%20spent%20all%20day%20on%20it%20already!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-279461%22%20slang%3D%22en-US%22%3ERe%3A%20I%20cannot%20get%20Set-PnPFileCheckedIn%20to%20work%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-279461%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F218294%22%20target%3D%22_blank%22%3E%40Luis%20Duran%3C%2FA%3E%26nbsp%3BI've%20just%20tried%20running%20your%20code%20and%20for%20me%20it%20works.%20My%20code%20looks%20like%20this%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%24folder%20%3D%20%22%2FShared%20Documents%22%3CBR%20%2F%3E%24filesinfolder%20%3D%20Get-PnPFolderItem%20-FolderSiteRelativeUrl%20%24folder%3CBR%20%2F%3E%3CBR%20%2F%3Eforeach(%24file%20in%20%24filesInFolder)%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%20%24filepath%20%3D%20%22%24(%24folder)%2F%24(%24file.Name)%22%3CBR%20%2F%3E%20Set-PnPFileCheckedIn%20-Url%20%24filePath%20-CheckinType%20MajorCheckIn%20-Comment%20%22Checked%20in%20by%20Script%22%3CBR%20%2F%3E%7D%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20would%20suggest%20checking%20the%20version%20of%20the%20PnP%20PowerShell%20Commands%20that%20you're%20running%3A%3C%2FP%3E%3CPRE%3EGet-Module%3C%2FPRE%3E%3CP%3EMy%20local%20version%20is%26nbsp%3B3.2.1810.0%2C%20so%20I'd%20suggest%20updating%20your%20PS%20modules%20if%20you're%20at%20an%20earlier%20version%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3EUpdate-Module%20SharePointPnPPowerShellOnline%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20hope%20that%20helps%2C%20if%20not%20please%20let%20me%20know%20and%20I'll%20have%20another%20look%20for%20you%20%3A)%3C%2Fimg%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

Here is the part of the code that does the checkin for files in a folder

$folder = "/Documents" 

$filesInFolder = Get-PnPFolderItem -FolderSiteRelativeUrl $folder -ItemType File
foreach($file in $filesInFolder)
{
    if($file.Level -eq "Checkout") {
       $filePath = ($folder + "/" + $file.Name)
        Set-PnPFileCheckedIn -Url $filePath -CheckinType MajorCheckIn -Comment "Checked in by Script"
}

I keep getting the error:

Set-PnpFileCheckedIn : serverRelativeUrl

Parameter name: Specified value is not supported for the serverRelativeUrl parameter

 

I have tried every variation of the url I can think of :

"/Documents/test.txt"

"Documents/test.txt"

"/sites/testsite/Documents/test.txt"

etc...

 

I need to check in 60,000 documents that a user uploaded checked out and nobody can see them. They are in multiple folders. I thought that this would be an easy fix, but I have spent all day on it already!

1 Reply

Hi @Luis Duran I've just tried running your code and for me it works. My code looks like this:

 

$folder = "/Shared Documents"
$filesinfolder = Get-PnPFolderItem -FolderSiteRelativeUrl $folder

foreach($file in $filesInFolder)
{
$filepath = "$($folder)/$($file.Name)"
Set-PnPFileCheckedIn -Url $filePath -CheckinType MajorCheckIn -Comment "Checked in by Script"
}

 

I would suggest checking the version of the PnP PowerShell Commands that you're running:

Get-Module

My local version is 3.2.1810.0, so I'd suggest updating your PS modules if you're at an earlier version

 

Update-Module SharePointPnPPowerShellOnline

 

I hope that helps, if not please let me know and I'll have another look for you :)