I want to upload the same file to several site collections with the same hierarchy in all site collections. I want to use PowerShell and enable automatic registration / registration features.
I can upload the file to SharePoint. Below is the code.
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") > $null
$path = "D:\ABC\DEF\26Nov\";
# create the Variable destination and pass the URL of the SharePoint List
$destination = "complete URL of File 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
# "For Each" loop will upload all of the files one by one onto the destination using the UploadFile method
Get-ChildItem $path | ForEach-Object { $webclient.UploadFile($destination + "/" + $_.Name, "PUT", $_.FullName)};
In this code, the file is uploaded but uploaded. I want it to be checked automatically. In case the file is there, first select and then write.
Please help me with this, as I have already spent 2 days in it. But nothing happens. Thank you very much for your support.
Hello
Kishana