diff --git a/Lists and Libraries Management/Checkout/Powershell/SPServer/Find all checked out files in SharePoint library and check them in/Capture7.PNG b/Lists and Libraries Management/Checkout/Powershell/SPServer/Find all checked out files in SharePoint library and check them in/Capture7.PNG new file mode 100644 index 00000000..4e9807f5 Binary files /dev/null and b/Lists and Libraries Management/Checkout/Powershell/SPServer/Find all checked out files in SharePoint library and check them in/Capture7.PNG differ diff --git a/Lists and Libraries Management/Checkout/Powershell/SPServer/Find all checked out files in SharePoint library and check them in/FindCheckedOutFilesandCheckThemInSPServer.ps1 b/Lists and Libraries Management/Checkout/Powershell/SPServer/Find all checked out files in SharePoint library and check them in/FindCheckedOutFilesandCheckThemInSPServer.ps1 new file mode 100644 index 00000000..25eb11de --- /dev/null +++ b/Lists and Libraries Management/Checkout/Powershell/SPServer/Find all checked out files in SharePoint library and check them in/FindCheckedOutFilesandCheckThemInSPServer.ps1 @@ -0,0 +1,100 @@ +function Get-SPOFolderFiles +{ +param ( + [Parameter(Mandatory=$true,Position=1)] + [string]$Username, + [Parameter(Mandatory=$true,Position=2)] + [string]$Url, + [Parameter(Mandatory=$true,Position=3)] + $password, + [Parameter(Mandatory=$true,Position=4)] + [string]$ListTitle + ) + +# Create context and test the connection + $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) + $ctx.Credentials = New-Object System.Net.NetworkCredential($Username, $password) + $ctx.Load($ctx.Web) + $ctx.ExecuteQuery() + + + $ll=$ctx.Web.Lists.GetByTitle($ListTitle) + $ctx.Load($ll) + $ctx.ExecuteQuery() + $spqQuery = New-Object Microsoft.SharePoint.Client.CamlQuery + $spqQuery.ViewXml =""; + $itemki=$ll.GetItems($spqQuery) + $ctx.Load($itemki) + $ctx.ExecuteQuery() + + foreach($item in $itemki) + { + + Write-Host $item["FileRef"] $item.ElementType + + $file = + $ctx.Web.GetFileByServerRelativeUrl($item["FileRef"]); + $ctx.Load($file) + $ctx.Load($file.Versions) + + $ctx.Load($file.ListItemAllFields) + $Author=$file.Author + $CheckedOutByUser=$file.CheckedOutByUser + $LockedByUser=$file.LockedByUser + $ModifiedBy=$file.ModifiedBy + $ctx.Load($Author) + $ctx.Load($CheckedOutByUser) + $ctx.Load($LockedByUser) + $ctx.Load($ModifiedBy) + $ctx.Load($file.EffectiveInformationRightsManagementSettings) + $ctx.Load($file.Properties) + try + { + $ctx.ExecuteQuery() + } + catch + {} + + if($CheckedOutByUser.LoginName -ne $null){ + Write-Host $file.Name + Write-Host $CheckedOutByUser.LoginName + $file.CheckIn('Checked in automatically', 'MajorCheckIn') + $ctx.Load($file) + try + { + $ctx.ExecuteQuery() + Write-Host $file.Name " has been checked in" -ForegroundColor DarkGreen + } + catch [Net.WebException] + { + Write-Host $_.Exception.ToString() + } + + } + + + + } + } + + + + + + + + + +#Paths to SDK +Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll" +Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" + +#Enter the data +$AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString +$username="AwesomeMachine\administrator" +$Url="http://ThisIsSharePoint/sites/site1" +$ListTitle="Documents" + + + +Get-sPOFolderFiles -Username $username -Url $Url -password $AdminPassword -ListTitle $ListTitle \ No newline at end of file diff --git a/Lists and Libraries Management/Checkout/Powershell/SPServer/Find all checked out files in SharePoint library and check them in/description.md b/Lists and Libraries Management/Checkout/Powershell/SPServer/Find all checked out files in SharePoint library and check them in/description.md new file mode 100644 index 00000000..c6d6dd02 --- /dev/null +++ b/Lists and Libraries Management/Checkout/Powershell/SPServer/Find all checked out files in SharePoint library and check them in/description.md @@ -0,0 +1,46 @@ +The script requires SharePoint Online SDK. + + + +What does it do? + +The script finds all the checked out files in a single library and checks them in. + + + +How to use? + +1. Download and open the file. + +2. Refer the paths to the SDK: + + + +PowerShell +#Paths to SDK +Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll" +Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" + + +3. Enter your credentials, the url of the site and the name of the list + +PowerShell +#Enter the data +$AdminPassword=Read-Host -Prompt "Enter password" -AsSecureString +$username="AwesomeMachine\administrator" +$Url="http://ThisIsSharePoint/sites/site1" +$ListTitle="Documents" + +4. Save the file, close, and run the script in Powershell. + + + +The files will have the following check-in in their version history: + + + +If you want to change the comment's content, modify the following line in the script: + +PowerShell +$file.CheckIn('Checked in automatically', 'MajorCheckIn') +