嗨,我正在使用这个脚本上传一个文件到共享点上的库,但是我得到了这个错误,任何帮助都是非常感谢的。
$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
我正在使用共享点服务器管理shell。谢谢
发布于 2018-11-16 14:52:37
//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()我用了这个脚本,它现在起作用了。然而,另一个仍然不知道为什么它不工作,但这一个做同样的工作。
https://stackoverflow.com/questions/53324020
复制相似问题