mirror of
https://github.com/paradizelost/Powershell-Public.git
synced 2024-11-25 02:04:43 -06:00
Update teedy.ps1
This commit is contained in:
parent
39d4c22217
commit
480ce4920e
48
teedy.ps1
48
teedy.ps1
@ -148,50 +148,26 @@ function New-Document(){
|
||||
param(
|
||||
$title,
|
||||
$language='eng',
|
||||
#$tags='',
|
||||
$tag='',
|
||||
$file
|
||||
)
|
||||
if($file){
|
||||
$fileids= Add-File -Files $file
|
||||
}
|
||||
$tagid=$taghash[$tag].id
|
||||
if(-not $tagid){
|
||||
$tagid=new-tag -TagName $tag
|
||||
}
|
||||
$doctocreate=@{
|
||||
title=$title;
|
||||
language="eng";
|
||||
tags= $tagid;
|
||||
}
|
||||
$doctocreate
|
||||
$newdocid = (Invoke-RestMethod -uri "$siteurl/api/document" -Headers $headers -Method PUT -body $doctocreate -ContentType 'application/x-www-form-urlencoded').id
|
||||
attach-file -documentid $newdocid -fileid $fileids
|
||||
}
|
||||
function New-multitagDocument(){
|
||||
param(
|
||||
$title,
|
||||
$language='eng',
|
||||
#$tags='',
|
||||
$tag,
|
||||
$tags,
|
||||
$file
|
||||
)
|
||||
if($file){
|
||||
$fileids= Add-File -Files $file
|
||||
}
|
||||
update-taghash
|
||||
$tagid=$taghash[$tag].id
|
||||
if(-not $tagid){
|
||||
$tagid=new-tag -TagName $tag
|
||||
$mytags=@()
|
||||
foreach($mytag in $tags){
|
||||
$mytags += $taghash[$mytag].id
|
||||
}
|
||||
$doctocreate=@{
|
||||
title=$title;
|
||||
language=$language;
|
||||
tags= @{'0f142bff-7922-4c70-8ad2-f492cfd2e5ec';'07002700-01d8-4547-80b9-c59a7c80f2d6'};
|
||||
}
|
||||
$doctocreate
|
||||
$newdocid = (Invoke-RestMethod -uri "$siteurl/api/document" -Headers $headers -Method PUT -body $doctocreate -ContentType 'application/x-www-form-urlencoded').id
|
||||
$title=[System.Web.HttpUtility]::UrlEncode($title)
|
||||
$basequery = "title=$title&language=$language"
|
||||
if ($tags) { $tagsquery = '&tags={0}' -f ($mytags -join '&tags=') }
|
||||
|
||||
$newdocid = (Invoke-RestMethod -uri "$siteurl/api/document" -Headers $headers -Method PUT -body "$($basequery)$($tagsquery)" -ContentType 'application/x-www-form-urlencoded').id
|
||||
if($file){
|
||||
attach-file -documentid $newdocid -fileid $fileids
|
||||
}
|
||||
$newdocid
|
||||
}
|
||||
Function Add-File(){
|
||||
param(
|
||||
|
Loading…
Reference in New Issue
Block a user