1

I am working with Sitecore 10 and using powershell 6.2 version when trying to publish an item to multiple targets at a time, getting an error while using this SPE code:

 Publish-Item -Item $item -Target "web","wed cd1"
1
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. Nov 23, 2023 at 12:37

3 Answers 3

2

For this to work, you need to provide target attribute in publish command. It accepts list so as you have multiple target then provide them accordingly.

e.g.

get-item '/sitecore/content/path' | publish-item -target @('web','web.staging')

if it is single database then you can simple give it as string :

get-item '/sitecore/content/path' | publish-item -target @('web') or get-item '/sitecore/content/path' | publish-item -target 'web' Hope this will solve your problem

4
  • Thank you so much Rinku it works!!! Nov 23, 2023 at 12:49
  • Its great that it helped, please accept the answer as well.
    – Rinku Jain
    Nov 23, 2023 at 12:50
  • 1
    It Works, Thank You !!
    – Anu Mathew
    Jan 23 at 5:21
  • @AnuMathew I am glad that it helped....thanks for your update...👍
    – Rinku Jain
    Feb 15 at 13:09
0

If publishing from content editor wors fine then it should also work from powershell . You can use next powershell code (you need to change item path) :

$targets = [string[]]@('web','internet')
Publish-Item -Path master:\content\home -Target $targets
0

If you go to https://doc.sitecorepowershell.com/appendix/common/publish-item, it has an exact example that shall serve your purpose.All you need to do is put the targets in an array (rather than supplying them as comma separated strings)-

PS master:\> $targets = [string[]]@('web','internet')
PS master:\> Publish-Item -Path master:\content\home -Target $targets

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.