これらのコード スニペットを PowerShell に変換しようとしました。
ClientContext context = new ClientContext("http://spdevinwin");
2:
3: Web web = context.Web;
4:
5: FileCreationInformation newFile = new FileCreationInformation();
6: newFile.Content = System.IO.File.ReadAllBytes(@"C:\Work\Files\17580_FAST2010_S05_Administration.pptx");
7: newFile.Url = "17580_FAST2010_S05_Administration 4MB file uploaded via client OM.pptx";
8:
9: List docs = web.Lists.GetByTitle("Documents");
10: Microsoft.SharePoint.Client.File uploadFile = docs.RootFolder.Files.Add(newFile);
11: context.Load(uploadFile);
12: context.ExecuteQuery();
13: Console.WriteLine("done");
と:
// FileInfo in System.IO namespace
var fileCreationInformation = new FileCreationInformation();
byte[] bytefile = System.IO.File.ReadAllBytes(“c:\\test\Test2.txt”);
fileCreationInformation.Content = bytefile;
fileCreationInformation.Overwrite = true;
fileCreationInformation.Url = “http://astro/MyLibrary/MyFolder/Test2.txt”;
// CurrentList is a client OM List object
CurrentList.RootFolder.Files.Add(fileCreationInformation);
Context.ExecuteQuery();
しかし、Update() および Add($file) メソッドでエラーが発生します