-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNew-LanguageCopy.ps1
More file actions
88 lines (65 loc) · 2.62 KB
/
New-LanguageCopy.ps1
File metadata and controls
88 lines (65 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
function New-LanguageCopy {
[CmdletBinding()]
param (
[Parameter(ValueFromPipelineByPropertyName = $True)]
[String]
$ServerName,
[Parameter(ValueFromPipelineByPropertyName = $True)]
[String]
$Path,
[Parameter(ValueFromPipelineByPropertyName = $True)]
[String]
$Deep,
[Parameter(ValueFromPipelineByPropertyName = $True)]
[String]
$Language,
[Parameter(ValueFromPipelineByPropertyName = $True, Mandatory = $True)]
[String]
$SourceLanguage
)
begin {
}
process {
$server = $aemEnv | Where-Object -Property name -Value $ServerName -eq
if ($server -eq $null) {
Write-Error -Message "ServerName $ServerName is not found."
return;
}
$headers = @{
Authorization = Get-BasicAuthorizationValue -Username $server.username -Password $server.password;
"Content-Type" = "application/x-www-form-urlencoded";
"User-Agent" = "curling"
}
$form = @{
"_charset_" = "utf-8"
":status" = "browser"
"payloadType" = "JCR_PATH"
"model" = "/etc/workflow/models/wcm-translation/create_language_copy/jcr:content/model"
"createNonEmptyAncestors" = "true"
"deep" = $Deep
"payload" = $Path
"projectFolderPath" = ""
"projectFolderLanguageRefCount" = "1"
"language" = $Language
"projectTitle" = ""
"projectType" = "add_structure_only"
"workflowTitle" = "Copy Structure $Path"
}
$createdPath = $Path -replace $SourceLanguage, $Language
$obj = New-Object -TypeName psobject
$obj | Add-Member -MemberType NoteProperty -Name ServerName -Value $ServerName
$obj | Add-Member -MemberType NoteProperty -Name Path -Value $createdPath
try {
$url = $server.url
$res = Invoke-WebRequest -Uri "$($url)/etc/workflow/instances" -Method Post -Headers $headers -Body $form
$obj | Add-Member -MemberType NoteProperty -Name Created -Value True
}
catch {
# throw $_.Exception
$obj | Add-Member -MemberType NoteProperty -Name Created -Value False
}
Write-Output $obj
}
end {
}
}