Невозможно проверить аргумент в параметре 'Кодировка' PowerShell - PullRequest
0 голосов
/ 15 ноября 2018

Привет! Я использую этот скрипт для загрузки файла в библиотеку на точке обмена, но я получаю эту ошибку, любая помощь приветствуется.

 $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

Я использую оболочку администратора сервера share point. спасибо

1 Ответ

0 голосов
/ 16 ноября 2018
//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()

Я использовал этот скрипт, он работает сейчас.Однако, другой все еще не понимает, почему он не работает, но этот делает ту же работу.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...