嗨,我正在使用此脚本将文件上传到共享点上的库中,但是遇到任何帮助,我都会收到此错误。
$Output = "c:\temp\users_PermisionReport.txt"
$WebURL = "http://url"
$ListName = "Documents"
//Create something to upload, in this case a list of all sites
Get-SPSite | Out-File -FilePath "url" $Output
//Upload the results to SharePoint
$File = Get-Item $Output
$Stream = $File.OpenRead()
$Web = Get-SPWeb $WebURL
$List = $Web.Lists["$ListName"]
$FileCollection = $List.RootFolder.Files
$FileCollection.Add($File.Name,$Stream,$true)
$Stream.Close()
$File.Delete()
Out-File : Cannot validate argument on parameter 'Encoding'. The argument
"c:\temp\users_PermisionReport.txt" does not
belong to the set
"unknown,string,unicode,bigendianunicode,utf8,utf7,utf32,ascii,default,oem"
specified by the
ValidateSet attribute. Supply an argument that is in the set and then try
the command again.
At C:\Users\balaji.chode\Desktop\UpDoc.ps1:6 char:59
+ Get-SPSite | Out-File -FilePath "url" $Output
+ ~~~~~~~
+ CategoryInfo : InvalidData: (:) [Out-File],
ParameterBindingValidationException
+ FullyQualifiedErrorId :
ParameterArgumentValidationError,Microsoft.PowerShell.Commands.OutFileCommand
我正在使用共享点服务器管理外壳。谢谢
答案 0 :(得分:0)
//Set the variables
$WebURL = “http://sharepoint:20000/ubt/it/”
$DocLibName = “Documents”
$FilePath = “c:\temp\users_PermisionReport2.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
$Files.Add($DocLibName +"/" + $FileName,$File.OpenRead(),$false)
$web.Dispose()
我使用了这个脚本,它现在正在工作。但是,另一个人仍然不为什么它不起作用,但是这个人却做同样的工作。