powershell Set-DxAddon.ps1将SDL Tridion Sites 9.1(及更高版本)附加组件上载到附加服务

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell Set-DxAddon.ps1将SDL Tridion Sites 9.1(及更高版本)附加组件上载到附加服务相关的知识,希望对你有一定的参考价值。

# Usage examples
#   .\Set-DxAddon.ps1 -Url "http://server:83" -Path addon.zip
#   .\Set-DxAddon.ps1 -Path addon.zip

param (
    [parameter(Mandatory=$false, HelpMessage="Tridion DX Add-on service URL. Defaults to 'http://localhost:83'")]
    [string] $Url = "http://localhost:83",

    [parameter(Mandatory=$true, HelpMessage="Path to to the add-on.")]
    [string] $Path
)

$ErrorActionPreference = "Stop"

if(-not (Test-Path $Path))
{
    Write-Error "File '$Path' does not exist"
}

$filename = Split-Path $Path -Leaf
$fileBytes = [System.IO.File]::ReadAllBytes($Path);
$fileEnc = [System.Text.Encoding]::GetEncoding('ISO-8859-1').GetString($fileBytes);
$boundary = [System.Guid]::NewGuid().ToString(); 
$LF = "`r`n";
$bodyLines = ( 
    "--$boundary",
    "Content-Disposition: form-data; name=`"File`"; filename=`"$filename`"",
    "Content-Type: application/x-zip-compressed$LF",
    $fileEnc,
    "--$boundary--$LF" 
) -join $LF

$postUrl = $Url + "/addon/api/v1/addons"
Invoke-RestMethod -Uri $postUrl -Method Post -ContentType "multipart/form-data; boundary=`"$boundary`"" -Body $bodyLines

以上是关于powershell Set-DxAddon.ps1将SDL Tridion Sites 9.1(及更高版本)附加组件上载到附加服务的主要内容,如果未能解决你的问题,请参考以下文章

powershell怎么运行

powershell PowerShell:启动PowerShell作为其他用户提升

powershell [提示输入powershell] #powershell #input #prompt

powershell 测量PowerShell命令或PowerShell脚本的速度

powershell远程下载exe并执行

powershell 使用啥端口