Exception calling "Update" with "0" argument(s): "To add an item to a document library, use SPFileCollection.Add()"
Hi i am trying to add a new item and update existing field value in a document library with powershell
but i receive below error message.
PS C:\Users\spfarm> C:\Scripts\add.ps1
Exception calling "Update" with "0" argument(s): "To add an item to a document
library, use SPFileCollection.Add()"
At C:\Scripts\add.ps1:24 char:16
+ $newItem.Update <<<< ()
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
#Add SharePoint PowerShell Snapin which adds SharePoint specific cmdlets
Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue
#Variables that we are going to use for list editing
$webURL = "http://tspmcwfe:89"
$listName = "test"
#Get the SPWeb object and save it to a variable
$web = Get-SPWeb $webURL
#Get the SPList object to retrieve the "Demo List"
$list = $web.Lists[$listName]
#Create a new item
$newItem = $list.Items.Add()
#Add properties to this list item
$newItem["Title"] = "My second item!"
$newItem["Info"] = "s15"
#Update the object so it gets saved to the list
$newItem.Update()
$web.Dispose()
adil
Hi Adil,
Document Library is different from a normal list. The document library contains files inside it. You need to update the code to add a document to the library. Then you can get hold of the List Item represented by that file and update its properties. Here
is an example:
$WebURL = "http://aissp2013/sites/TestSite"
$DocLibName = "Docs"
$FilePath = "c:\blogs.txt"
# Get a variable that points to the folder
$Web = Get-SPWeb $WebURL
$List = $Web.GetFolder($DocLibName)
$Files = $List.Files
# Get just the name of the file from the whole path
$FileName = $FilePath.Substring($FilePath.LastIndexOf("\")+1)
# Load the file into a variable
$File= Get-ChildItem $FilePath
# Upload it to SharePoint
$spFile = $Files.Add($DocLibName +"/" + $FileName,$File.OpenRead(),$false)
$item = $spFile.Item
$item["Title"] = "New Title"
$item.Update()
$web.Dispose()
Blog | SharePoint Learnings CodePlex Tools |
Export Version History To Excel |
Autocomplete Lookup Field
Similar Messages
-
Hi,
I have a Sharepoint 2013 farm I am trying to provision search for (not the same as my other thread). However, I get the below error:
Exception calling "Activate" with "0" argument(s): "Topology does not contain any components of type Microsoft.Office.Server.Search.Administration.Topology.AdminComponent"
In my script, I have the following:
New-SPEnterpriseSearchAdminComponent -SearchTopology $clone -SearchServiceInstance $SearchServiceInstanceServer3 -ErrorAction SilentlyContinue
So I am not sure why the error happens, when I am trying to set this component. However, it's not the first component to be set (index partition on non-local servers first). I can make it first, but why does this error happen?
UPDATE: I have noticed that the usage and health proxy on my farm is/was stopped, but I am not able to access the server(s) to look at this right now. Could this cause this issue?Do you already have Admin component running for the Search Service Application?
Usage and Health Service will not cause this issue.
Please also refer to below discussion to see if it helps:
http://social.technet.microsoft.com/Forums/sharepoint/en-US/02f0b072-aa3a-4b7f-9662-2caf373d1e57/setspenterprisesearchtopology-identity-newtopology?forum=sharepointgeneral
Warm Regards,
Bhavik K Jain
Sr. Software Engineer - SharePoint Administration
Please vote if my reply helps and ensure that you mark a question as Answered once you receive a satisfactory response. -
Hi,
I am getting an error System.Management.Automation.MethodInvocationException: Exception calling "ExecuteQuery" with "0" argument(s): "$Resources:core,ImportErrorMessage;" ---> Microsoft.SharePoint.Client. ServerException:
$Resources:core,ImportErrorMessage;
Following is my powershell script on line
$context.ExecuteQuery(); it is throwing this error.
function AddWebPartToPage([string]$siteUrl,[string]$pageRelativeUrl,[string]$localWebpartPath,[string]$ZoneName,[int]$ZoneIndex)
try
#this reference is required here
$clientContext= [Microsoft.SharePoint.Client.ClientContext,Microsoft.SharePoint.Client, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c]
$context=New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)
write-host "Reading file " $pageRelativeUrl
$oFile = $context.Web.GetFileByServerRelativeUrl($pageRelativeUrl);
$limitedWebPartManager = $oFile.GetLimitedWebPartManager([Microsoft.Sharepoint.Client.WebParts.PersonalizationScope]::Shared);
write-host "getting xml reader from file"
$xtr = New-Object System.Xml.XmlTextReader($localWebpartPath)
[void] [Reflection.Assembly]::LoadWithPartialName("System.Text")
$sb = new-object System.Text.StringBuilder
while ($xtr.Read())
$tmpObj = $sb.AppendLine($xtr.ReadOuterXml());
$newXml = $sb.ToString()
if ($xtr -ne $null)
$xtr.Close()
#Add Web Part to catalogs folder
write-host "Adding Webpart....."
$oWebPartDefinition = $limitedWebPartManager.ImportWebPart($newXml);
$limitedWebPartManager.AddWebPart($oWebPartDefinition.WebPart, $ZoneName, $ZoneIndex);
$context.ExecuteQuery();
write-host "Adding Web Part Done"
catch
write-host "Error while 'AddWebPartToPage'" $_.exception| format-list * -force
ERROR:
Error while 'AddWebPartToPage' System.Management.Automation.MethodInvocationException: Exception calling "ExecuteQuery" with "0" argument(s): "$Resources:core,ImportErrorMessage;" ---> Microsoft.SharePoint.Client.
ServerException: $Resources:core,ImportErrorMessage;
at Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream responseStream)
at Microsoft.SharePoint.Client.ClientRequest.ProcessResponse()
at Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()
at ExecuteQuery(Object , Object[] )
at System.Management.Automation.DotNetAdapter.AuxiliaryMethodInvoke(Object target, Object[] arguments, MethodInformation methodInformation, Object[] originalArguments)
--- End of inner exception stack trace ---
at System.Management.Automation.DotNetAdapter.AuxiliaryMethodInvoke(Object target, Object[] arguments, MethodInformation methodInformation, Object[] originalArguments)
at System.Management.Automation.DotNetAdapter.MethodInvokeDotNet(String methodName, Object target, MethodInformation[] methodInformation, Object[] arguments)
at System.Management.Automation.Adapter.BaseMethodInvoke(PSMethod method, Object[] arguments)
at System.Management.Automation.ParserOps.CallMethod(Token token, Object target, String methodName, Object[] paramArray, Boolean callStatic, Object valueToSet)
at System.Management.Automation.MethodCallNode.InvokeMethod(Object target, Object[] arguments, Object value)
at System.Management.Automation.MethodCallNode.Execute(Array input, Pipe outputPipe, ExecutionContext context)
at System.Management.Automation.ParseTreeNode.Execute(Array input, Pipe outputPipe, ArrayList& resultList, ExecutionContext context)
at System.Management.Automation.StatementListNode.ExecuteStatement(ParseTreeNode statement, Array input, Pipe outputPipe, ArrayList& resultList, ExecutionContext context)
Thanks Sethu for your comments. However i am running this powershell directly on server so believe
SharePointOnlineCredentials is not required.
I have tried it but still giving me same error -
Query AD cause Exception calling "FindAll" with "0" argument(s)
Hi all,
When I query an entry property of AD with PowerShell, i got some problems. Here is the script, what's wrong ? Any idea? Thanks!
Cause error at last line code. (Exception calling "FindAll" with "0" argument(s): "There is no such object on the server)
$MailboxServer = Get-MailboxServer -Identity $Env:COMPUTERNAME -ErrorAction SilentlyContinue
$dc = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()
$exchOAB = New-Object System.DirectoryServices.DirectoryEntry("LDAP://" + $dc.Name + "/cn=Offline Address Lists,cn=Address Lists Container, " + $MailboxServer.DistinguishedName)
$objSearcher = New-Object System.DirectoryServices.DirectorySearcher
$objSearcher.SearchRoot = $exchOAB
$objSearcher.PageSize = 1000
$objSearcher.SearchScope = "OneLevel"
$objSearcher.Filter = "(objectClass=msExchOAB)"
$powershellOAB = $objSearcher.FindAll()This is one of, now, four duplicate posts.
¯\_(ツ)_/¯ -
I have CSV file which has sdimiler data I am inserting those date to desinated table and while executing this query mentioned below I get error mentioned in TITLE
insert into SU_EDIT_DETAIL(EDIT_FUNCTION, TABLE_FUNCTION, CODE_FUNCTION, CODE_TYPE,CODE_BEGIN, CODE_END, EXCLUDE, INCLUDE_X, OP_NBR, TRANSCODE, VOID, YMDEFF, YMDEND, YMDTRANS)"
select $($line."EDIT_FUNCTION"),($line."TABLE_FUNCTION"), ($line."CODE_FUNCTION"),'DIAG', ($line."CODE_BEGIN"), ($line."CODE_END"),' ',' ',' ','MIS', 'C',' ',20141001, 99991231, 20131120
from dual where not exists(select * from SU_EDIT_DETAIL where (EDIT_FUNCTION = ($line."EDIT_FUNCTION") and TABLE_FUNCTION = ($line."TABLE_FUNCTION")
and CODE_BEGIN= ($line."CODE_BEGIN")
and CODE_END= ($line."CODE_END")));
commit;
Vijay PatelThis SQL appears to be Oracle PL/SQL. You may want to post in the Oracle forum. If you are habving issues with the ADO.NET objects then you need to supply more of your code.
¯\_(ツ)_/¯ -
Hi All,
We have SharePoint Production server 2013 where users are complaining that they are not able to copy or move files from one document library to another document library using “Open with Explorer” functionality.
We tried to activate publishing features on production server but it did not work. We users reported following errors:
Copying files from one document library to another document library:
Tried to map the document libraries and still not get the error to copy files:
In our UAT environment we are able to copy and move folders from using “Open with Explorer” though.
We have tried to simulate in the UAT environment but could not reproduce the production environment.
Any pointers about this issue would be highly appertained.
Thanks in advance
Regards,
Aroh
Aroh ShuklaHi John and all,
One the newly created web applications that we created few days back and navigated to document library, clicked on “Open with Explorer”, we get this error.
We're having a problem opening this location in file explorer. Add this website to your trusted and try again.
We added to the trusted site in Internet Explorer for this web application, cleared the cache and open the site with same document library but still get the same above error.
However, another existing web application (In same the Farm) that we are troubleshooting at the moment, we are able click on “Open with Explorer”, login in credentials opens and we entered the details we are able to open the document
library and tried to follow these steps:
From Windows Explorer (using with Open with Explorer), tried to copy or move a files to
source document library.
From Windows Explorer moved this file to another destination document library and we got this error.
What we have to achieve is users should be able to copy files and folders using
Open with Explorer functionality. We don’t know why Open with Explorer
functionality not work working for our environment.
Are we doing something wrong?
We have referred to following websites.
we hope concepts of copying / Moving files are similar as SharePoint 2010. Our production environment is SharePoint 2013.
http://www.mcstech.net/blog/index.cfm/2012/1/4/SharePoint-2010-Moving-Documents-Between-Libraries https://andreakalli.wordpress.com/2014/01/28/moving-or-copying-files-and-folders-in-sharepoint/
Please advise us. Thank you.
Regards,
Aroh
Aroh Shukla -
How to update managed metadata column for all file in document library using powershell
Hi,
How to update managed metadata column for all file in document library using powershell?
Any help on it.
Thanks & REgards
Poomani SankaranHi TanPart,
I have changed the code which you have give in order to get the files from SharePoint 2010 Foundation Document Library.But i am getting below error in powershell.
Property 'ListItemCollectionPosition' cannot be found on this object; make sure it exists and is settable.
Could you tell me which is the issues in it?
See the code below.
$web = Get-SPWeb http://ntmoss2010:9090/Site
$list = $web.Lists["DocLib"]
$query = New-Object Microsoft.SharePoint.SPQuery
$query.ViewAttributes = "Scope='Recursive'";
$query.RowLimit = 2000
$caml = '<Where><Contains><FieldRef Name="Title" /><Value Type="Text">Process Documents/Delivery</Value></Contains></Where>' +
'<OrderBy Override="TRUE"><FieldRef Name="ID"/></OrderBy>'
$query.Query = $caml
do
$listItems = $list.GetItems($query)
$spQuery.ListItemCollectionPosition = $listItems.ListItemCollectionPosition
foreach($item in $listItems)
#Cast to SPListItem to avoid ambiguous overload error
$spItem = [Microsoft.SharePoint.SPListItem]$item;
Write-Host $spItem.Title
while ($spQuery.ListItemCollectionPosition -ne $null)
Thanks & Regards
Poomani Sankaran -
Hello, I have updated to the newest version of Pages and yet when I open a document to use it says, "You need a newer version of Pages to open this document." When I got to install it again it says I have already done that. Anybody have any tricks? Thanks!
You have 2 versions of Pages on your Mac.
Pages 5 is in your Applications folder.
Pages '09/'08 is in your Applications/iWork folder.
You are alternately opening the wrong versions.
Pages '09/'08 can not open Pages 5 files and you will get the warning that you need a newer version.
Pages 5/5.01 can not open Pages 5.1 files and you will get the warning that you need a newer version.
Pages 5.1 sometimes can not open its own files and you will get the warning that you need a newer version.
Pages 5 can open Pages '09 files but may damage/alter them. It can not open Pages '08 files at all.
Once opened and saved in Pages 5 the Pages '09 files can not be opened in Pages '09.
Anything that is saved to iCloud is also converted to Pages 5 files.
All Pages files no matter what version and incompatibility have the same extension .pages.
Pages 5 files are now only compatible with themselves on a very restricted set of hardware, software and Operating Systems and will not transfer correctly on any other server software than iCloud.
Apple has not only managed to confuse all its users, but also itself.
Note: Apple has removed over 95 features from Pages 5 and added many bugs:
http://www.freeforum101.com/iworktipsntrick/viewforum.php?f=22&sid=3527487677f0c 6fa05b6297cd00f8eb9&mforum=iworktipsntrick
Archive/trash Pages 5, after exporting all Pages 5 files to Pages '09 or Word .docx, and rate/review it in the App Store, then get back to work.
Peter -
I repeatedly receive an error message when trying to sync my ipod touch with my itunes library with my new computer which reads, "Some of the items in the itunes library were not copied to the ipod because you are not authorized on this computer." However when I try and authorize my computer I always receive the message that this computer is authorized. What am I doing wrong? I'm missing about 100 songs as a result of this error!!
See:
iTunes Store: About authorization and deauthorization
iTunes repeatedly prompts to authorize computer to play iTunes Store purchases
Could the items be purchased by another account? -
did the usual software update on my mac (older)
Model Name: iMac
Model Identifier: iMac4,1
Processor Name: Intel Core Duo
Processor Speed: 2 GHz
Number Of Processors: 1
Total Number Of Cores: 2
L2 Cache: 2 MB
Memory: 2 GB
Bus Speed: 667 MHz
Boot ROM Version: IM41.0055.B08
SMC Version (system): 1.1f5
Serial Number (system): QP6300JZU2S
Hardware UUID: 00000000-0000-1000-8000-0016CB8A01BF
when I open iphoto, says
You can’t open your current photo library using this version of iPhoto. You have made changes to your photo library using a newer version of iPhoto. Please quit and use the latest version of iPhoto.
software is up to date. can't even access pics.
can this computer run the maverick version of iphoto?What system and iPhoto versions do you have currently and what versions did you have before the software update? What did you update?
OT -
Call method with an argument from another view controller
I have a UIViewController MainViewController that brings up a modal view that is of the class AddPlayerViewController. When the user clicks 'Save' in the modal view I need to pass the Player data (which is a Player class) from the modal view to the MainViewController in addition to triggering a method in the MainViewController. What's the best way to accomplish this? I'm new to cocoa and have only tried using delegates and some ugly hacks to no avail.
Thanks for the help.If I understand correctly, you have:
1. A model object, Player.
2. A top view controller, MainViewController.
3. Another view controller, AddPlayerViewController, which MainViewController displays modally.
I'm guessing that AddPlayerViewController creates a new Player object and lets the user set its values, and you need a way to get that new Player into MainViewController once they're done.
So, here's what I'd do:
1. Create an AddPlayerViewControllerDelegate protocol. It should declare two methods, "- (void)addPlayerViewController:(AddPlayerViewContrller*)controller didAddPlayer:(Player*)newPlayer" and "- (void)addPlayerViewControllerNotAddingPlayer:(AddPlayerViewController*)controll er".
2. Add an attribute of type "id <AddPlayerViewControllerDelegate>" called delegate to AddPlayerViewController. Also add a property with "@property (assign)" and "@synthesize".
3. Modify AddPlayerViewController so that if you click the "Save" button, addPlayerViewController:didAddPlayer: gets called, passing "self" and the new Player object as the two arguments. Also arrange for clicking the "Cancel" button to call addPlayerViewControllerNotAddingPlayer:.
4. Modify MainViewController to declare that it conforms to AddPlayerViewControllerDelegate. Implement those two methods (addPlayerViewControllerNotAddingPlayer: might be an empty method if you don't want to do anything).
5. When you create your AddPlayerViewController, set its delegate to your MainViewController.
If you need more detail, let me know what parts you need me to elaborate on. -
Call function with select arguments
Hi Gurus,
I have problem to call function inside select statements as follow:
select a.ID_ELE2, a.ID_ELE3, a.DT_FIS_YR, c.NU_FIS_PER, c.dt,
(case
when c.ld is null then
GET_LD_CHECK (a.DT_FIS_YR,c.NU_FIS_PER, a.ID_ELE3, a.ID_ELE2) -- 1
-- GET_LD_CHECK ('2009',7, '8010', '7493') --- 2
else
c.ld
end ) description
from ACCOUNT a, TRANSACTION c
where a.DT_FIS_YR ='2009'
and a.ID_ELE3 <> '0000'
and c.TY_SRC not in ('CL', 'CN')
and a.DT_FIS_YR = c.nu_fis_yr
and a.AK = c.AK_FGCHAR
and trim(a.ID_ELE3) ='8010'
and c.NU_FIS_PER <> 14
order by 1,4,5,6
the 1 doesn't output result but the 2 it does! How can pass the select result to the function?
Thanks in advance for your help.
BenThe statement / function call seems to be ok. So there are not much chances left for your call to return different (=non) values.
1) It could be that you have different values in the column then during your test call.
2) Maybe your function raises an error and that error is supressed in some ugly WHEN OTHERS EXCEPTION => Solution: Get rid of the error handler.
3) datatype conversion. For example if a.dt_fis_yr is a number value, then you should test with number values and not with strings. GET_LD_CHECK (2009,7, '8010', '7493'). Same logic goes for the other paramters, make sure the datatype is correct and matches the function parameter. -
Calling RH_ShowLocalHelp with 5 arguments
Hello all,
I'm trying to make a context-sensitive help call from C#. According to the documentation at http://help.adobe.com/en_US/robohelp/robohtml/WS5b3ccc516d4fbf351e63e3d11aff59c571-7f39.ht ml , there's a function named RH_ShowLocalHelp that takes 5 parameters. Unfortunately, that function seems to be missing from the C# files that ship with RoboHelp 10 (the 4 arguments' version is in the file, though). Am I missing something in here? Am I not using the right files?
Thanks in advance,
--IgnacioI don't have an answer but maybe a look at www.wvanweelden.eu will help. Willam has a lot of information on calling help.
See www.grainge.org for RoboHelp and Authoring tips
@petergrainge -
Call apt with multiple arguments
Is it possible to call apt inside a java class and pass multiple .class files?
For example:
String[] args = new String[5];
args[0] = "-nowarn";
args[1] = "-XclassesAsDecls";
args[2] = "-classpath";
args[3] = System.getProperty("java.class.path");
args[4] = "packageName.FirstClass packageName.SecondClass";
return Main.process(new MyAnnotationProcessorFactory(),args);Result of the above example is:
error: Could not find class file for packageName.FirstClass packageName.SecondClass
1 errorThe class path contains classes that we need.
This example works:
String[] args = new String[6];
args[0] = "-nowarn";
args[1] = "-XclassesAsDecls";
args[2] = "-classpath";
args[3] = System.getProperty("java.class.path");
args[4] = "packageName.FirstClass";
args[5] = "packageName.SecondClass";
return Main.process(new IapiAnnotationProcessorFactory(),args);I replaced args[4] = "packageName.FirstClass packageName.SecondClass"; with a
args[4] = "packageName.FirstClass";
args[5] = "packageName.SecondClass"; -
How to call function with varray arguments .
Hi,
I've got function like this:
CREATE OR REPLACE
TYPE VARR_VARCHAR AS VARRAY(256) OF NVARCHAR2(500)
CREATE OR REPLACE
TYPE E_VARR_VARCHAR AS VARRAY(256) OF nVARCHAR2(4096)
FUNCTION find_id(
p_id IN VARCHAR2,
p_special_columns IN varr_varchar,
p_special_values IN e_varr_varchar,
RETURN VARCHAR2;How can I construct call to that function (nvarchar datatype is a need) using only pl/sql and can I do that with pure sql like select f() from dual; ?
I'm on 9.2.0.8 .
Regards
GregGselect find_id (p_id,VARR_VARCHAR('1','2','3'),e_varr_varchar('1','2','3')) from dual;
--sty.
Maybe you are looking for
-
Delete Empty Frames in Indesign through AppleScript
Hi Everyone, We have some users who mistakenly add empty frames in the indesign document. (these are generally very small for example {4.9786 in, 3.9402 in} etc) Can we identify such frames through an apple script. Usually the frames can be made as a
-
Can't export as Html (Waiting for all files to be ready...)
Made a bunch of updates last night to a client site. Everything looks great except I can't export as Html. Had my sister try to export on her computer and we both get to 87%, then it permanently stalls, saying "Waiting for all files to be ready" (Se
-
Wondering how Mail works in Lion. How does the type to find feature work? Is it improved from Snow Leopard? E.g. If you type Da, does it find the first message that is from Da...? If you do this again, what does it do? If you then type in Mi, does
-
Can't load firefox on my new iMac with lion
when i go to your download pack and click download, nothing happens. I also use safari which works. i have always used firefox as an alternate. can't seem to get it loaded on my new iMac.
-
Hi I am wanting to install Adobe photoshop elements 8 disk on our imac. I have just uninstalled it from our imac as we were getting messages about it missing components. When I install the disk into the cd drive on our mac it doesn't fire up or appea