I want to upload the same file to multiple site collection with the same hierarchy in all the site collection using powershell and the with functionality auto checkin/checkout.
I have able to upload the file in SharePoint. Below is the code. :
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") > $null
# create the Variable Path and Pass the source folder path
$path = “D:\ABC\DEF\26Nov\”;
# create the Variable destination and pass the URL of the SharePoint List
$destination = "complete URL will be mentioned here";
# Store the current user default credentials in the Variable Credentials
$credentials = [System.Net.CredentialCache]::DefaultCredentials;
# Create the object of the Webclient
$webclient = New-Object System.Net.WebClient;
# Pass the user credentials
$webclient.Credentials = $credentials; Get-ChildItem
Get-ChildItem $path | ForEach-Object { $webclient.UploadFile($destination + “/” + $_.Name, “PUT”, $_.FullName)};
For Each
loop will upload all of the files one by one onto the destination using the UploadFile method
By This code the file is upload but its checked, out . I want it to be checkin automatically and incase if file is there the auto-checkout and then checkin.
Please help me on this, as I have already spent 2 days in it. But nothing happens Thanks much for your support
Regards
Kishan