我有一个奇怪的案例,关于Sitecore扩展。我已经创建了一个基于.net的Cmdlet,在使用带有所需参数的导入命令之后,可以执行该命令。现在,我想通过在外部系统中调度这个cmdlet来实现这个cmdlet的自动化,因为我不信任Sitecore。为此,我在Sitecore中使用ISE编写了一个新函数,并将其保存为“Powershell脚本”项。以下是守则:
function Execute-Auto-Site-Backup {
<#
.SYNOPSIS
Backups the given site path while looking for delta based on last execution time.
.PARAMETER Item
Item to sync, Usually a Root Item, Need to specify Sitecore Guid of Root Item.
.PARAMETER ItemList
Specifies the list of item which need to be excluded, It is in pipe separated GUIDs.
.PARAMETER UserName
Sitecore Username for taret webservice "sitecore\admin"
.PARAMETER Password
Sitecore Password
.PARAMETER HostURL
Sitecore instance Host URL
.PARAMETER DBName
Sitecore target Database name, if not passed default is "master"
.PARAMETER LangName
Sitecore Source Language name, if not passed default is "en"
.PARAMETER IncludeChildren
Indicate if need to copy the all children till nth level of indicated root item, if not passed default is false which means it will execute for single item
.PARAMETER BackupMode
Indicate if need to create versions always or just update the existing latest version, if not passed default is true which means it will create version in the target item
.PARAMETER VersionNumber
Sitecore Version number of Item to get, Default will be the Latest if not provided. In case of multiple item it will always take latest version.
.PARAMETER LookupMode
To use History Engine, if not passed default is false which means always look in iterative mode from passed root node.
.PARAMETER DateTime
If LookupMode is History Engine than this parameter will define since when to look, ideally this is last time the backup job has run. Date Time should be in following format and as per server time zone '1/20/2015 3:30:00 PM'
.EXAMPLE
BackupMode as version(non-update) always and LookupMode is single item(non-history)
[string[]]$paracs=@("{7589EBFF-FB47-41A0-8712-E34623F5518E}","","sitecore\admin","target","http://10.0.0.5/","master","en","false","true","0","false","")
.EXAMPLE
BackupMode as version(non-update) always and LookupMode is iterative(non-history) in childrens
[string[]]$paracs=@("{7589EBFF-FB47-41A0-8712-E34623F5518E}","","sitecore\admin","target","http://10.0.0.5/","master","en","true","true","0","false","")
.EXAMPLE
BackupMode as update(non-version) always and LookupMode is iterative(non-history) in childrens
[string[]]$paracs=@("{7589EBFF-FB47-41A0-8712-E34623F5518E}","","sitecore\admin","target","http://10.0.0.5/","master","en","true","false","0","false","")
.EXAMPLE
BackupMode as update(non-version) always and LookupMode is single item(non-history)
[string[]]$paracs=@("{7589EBFF-FB47-41A0-8712-E34623F5518E}","","sitecore\admin","target","http://10.0.0.5/","master","en","false","false","0","false","")
.EXAMPLE
BackupMode as version(non-update) always and LookupMode is history(non-iterative)- most used way and preferred for automate backups
[string[]]$paracs=@("{7589EBFF-FB47-41A0-8712-E34623F5518E}","","sitecore\admin","target","http://10.0.0.5/","master","en","","true","0","true","1/20/2015 3:30:00 PM")
.EXAMPLE
BackupMode as update(non-version) always and LookupMode is history(non-iterative)
[string[]]$paracs=@("{7589EBFF-FB47-41A0-8712-E34623F5518E}","","sitecore\admin","target","http://10.0.0.5/","master","en","","false","0","true","1/20/2015 3:30:00 PM")
#>
[CmdletBinding()]
param(
[ValidateNotNullOrEmpty()]
[string]$Item,
[string]$ItemList,
[ValidateNotNullOrEmpty()]
[string]$UserName,
[ValidateNotNullOrEmpty()]
[string]$Password,
[ValidateNotNullOrEmpty()]
[string]$HostURL,
[ValidateNotNullOrEmpty()]
[string]$DBName,
[ValidateNotNullOrEmpty()]
[string]$LangName,
[string]$IncludeChildren="false",
[string]$BackupMode="true",
[string]$VersionNumber,
[string]$LookupMode="false",
[string]$DateTime
)
$path=$AppPath+"bin\PG.SharedSitecore.AssemblyTools.CoreSync.dll"
Import-Module $path -Verbose
[string[]]$paracs=@($Item,$ItemList,$UserName,$Password,$HostURL,$DBName,$LangName,$IncludeChildren,$BackupMode,$VersionNumber,$LookupMode,$DateTime)
Get-CoreSyncBackup -args $paracs
}现在我想从远程调用这个函数,我尝试使用Powershell RemoteAutomation.asmx & PowerShellWebService.asmx,但是没有什么用处,而且关于它的文档很少。例如,我尝试编写windows PS文件,我可以在作业服务器或任何其他调度程序中对其进行调度,因为它们大多支持powershell脚本:
$page=New-WebServiceProxy -Uri "http://audit.brand.com/console/services/RemoteAutomation.asmx"
$BackupFunction=@"
Execute-Script "master:/sitecore/system/Modules/PowerShell/Script Library/CoreSync/SyncorBackupFunc/";
Execute-Auto-Site-Backup "{7589EBFF-FB47-41A0-8712-E34623F5518E}" "" "sitecore\admin" "b" "http://audit.brand.com/" "master" "en" "true" "true" "" "" ""
"@
$returnVar=""
$page.ExecuteScriptBlock("sitecore\admin","b",$BackupFunction,$returnVar)
$returnvar我也试着跟着不起作用的
$page=New-WebServiceProxy -Uri "http://audit.brand.com/console/services/RemoteAutomation.asmx"
$BackupFunction=@"
master:/sitecore/system/Modules/PowerShell/Script Library/CoreSync/SyncorBackupFunc/
"@
$returnVar=""
$page.ExecuteScript("sitecore\admin","b",$BackupFunction,$returnVar)
$returnvar请指点我哪里错了。
发布于 2015-02-19 19:01:22
您试过应用我博客上的这篇文章?的解决方案吗?
它应该允许您在服务器上执行任意脚本块。
发布于 2016-01-03 19:14:28
从那时起,我们发布了一个SPE远程处理模块,您可以在本地机器上使用该模块与Sitecore的远程实例进行交互。
在这里阅读更多相关信息:https://sitecorepowershell.gitbooks.io/sitecore-powershell-extensions/content/remoting.html
https://stackoverflow.com/questions/28609633
复制相似问题