Sitecore Powershell Extensions not returning field source value
I'm trying to write a simple Powershell script that finds all General Link
fields and outputs the value of their Source
field.
$fields = Get-ChildItem -Path "master://sitecore/templates/user defined" -Recurse | Where-Object { $_.TemplateName -eq "Template field" -and $_.Type -eq "General Link" }
foreach ($field in $fields) {
Write-Host "Name: $($field.Name)"
Write-Host "Source: $($field.Source)"
Write-Host
}
Whenever I run it, however, the value from the Source
field is empty for all returned items.
I've confirmed that it is populated in at least some of the cases, but it never shows up in the report. I've tried several variations to get the value, too:
$fields | Show-ListView -property `
@{ Name="Path"; Expression={$_.Paths.Path} },
@{ Name="Source"; Expression={$_.Source} },
@{ Name="Source With Quotes"; Expression={$_."Source"} }
Versions
- Sitecore version: 8.1 Update 3
- Sitecore PowerShell Extensions version: 5.0.0.42513
powershell-extensions
add a comment |
I'm trying to write a simple Powershell script that finds all General Link
fields and outputs the value of their Source
field.
$fields = Get-ChildItem -Path "master://sitecore/templates/user defined" -Recurse | Where-Object { $_.TemplateName -eq "Template field" -and $_.Type -eq "General Link" }
foreach ($field in $fields) {
Write-Host "Name: $($field.Name)"
Write-Host "Source: $($field.Source)"
Write-Host
}
Whenever I run it, however, the value from the Source
field is empty for all returned items.
I've confirmed that it is populated in at least some of the cases, but it never shows up in the report. I've tried several variations to get the value, too:
$fields | Show-ListView -property `
@{ Name="Path"; Expression={$_.Paths.Path} },
@{ Name="Source"; Expression={$_.Source} },
@{ Name="Source With Quotes"; Expression={$_."Source"} }
Versions
- Sitecore version: 8.1 Update 3
- Sitecore PowerShell Extensions version: 5.0.0.42513
powershell-extensions
add a comment |
I'm trying to write a simple Powershell script that finds all General Link
fields and outputs the value of their Source
field.
$fields = Get-ChildItem -Path "master://sitecore/templates/user defined" -Recurse | Where-Object { $_.TemplateName -eq "Template field" -and $_.Type -eq "General Link" }
foreach ($field in $fields) {
Write-Host "Name: $($field.Name)"
Write-Host "Source: $($field.Source)"
Write-Host
}
Whenever I run it, however, the value from the Source
field is empty for all returned items.
I've confirmed that it is populated in at least some of the cases, but it never shows up in the report. I've tried several variations to get the value, too:
$fields | Show-ListView -property `
@{ Name="Path"; Expression={$_.Paths.Path} },
@{ Name="Source"; Expression={$_.Source} },
@{ Name="Source With Quotes"; Expression={$_."Source"} }
Versions
- Sitecore version: 8.1 Update 3
- Sitecore PowerShell Extensions version: 5.0.0.42513
powershell-extensions
I'm trying to write a simple Powershell script that finds all General Link
fields and outputs the value of their Source
field.
$fields = Get-ChildItem -Path "master://sitecore/templates/user defined" -Recurse | Where-Object { $_.TemplateName -eq "Template field" -and $_.Type -eq "General Link" }
foreach ($field in $fields) {
Write-Host "Name: $($field.Name)"
Write-Host "Source: $($field.Source)"
Write-Host
}
Whenever I run it, however, the value from the Source
field is empty for all returned items.
I've confirmed that it is populated in at least some of the cases, but it never shows up in the report. I've tried several variations to get the value, too:
$fields | Show-ListView -property `
@{ Name="Path"; Expression={$_.Paths.Path} },
@{ Name="Source"; Expression={$_.Source} },
@{ Name="Source With Quotes"; Expression={$_."Source"} }
Versions
- Sitecore version: 8.1 Update 3
- Sitecore PowerShell Extensions version: 5.0.0.42513
powershell-extensions
powershell-extensions
edited Feb 15 at 16:57
Dan Sinclair
asked Feb 15 at 15:06
Dan SinclairDan Sinclair
1,954525
1,954525
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
There is no Source
property on Sitecore.Data.Items.Item
class.
You need to get Source
field value e.g. like this:
foreach ($field in $fields) {
Write-Host "Name: $($field.Name)"
Write-Host "Source: $($field._.Source.Value)"
Write-Host
}
1
This example is making use of a custom object SPE adds to the item. You can use_
orPSFields
to get typed properties.
– Michael West
Feb 15 at 16:25
add a comment |
The issue is that the Source
field is of type Template Field Source
, which seems to not automatically emit a value if you simply access the field directly on the item ($field.Source
).
Instead, you must get the field and get the value from that field:
$field.Fields['Source'].Value
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "664"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsitecore.stackexchange.com%2fquestions%2f16819%2fsitecore-powershell-extensions-not-returning-field-source-value%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
There is no Source
property on Sitecore.Data.Items.Item
class.
You need to get Source
field value e.g. like this:
foreach ($field in $fields) {
Write-Host "Name: $($field.Name)"
Write-Host "Source: $($field._.Source.Value)"
Write-Host
}
1
This example is making use of a custom object SPE adds to the item. You can use_
orPSFields
to get typed properties.
– Michael West
Feb 15 at 16:25
add a comment |
There is no Source
property on Sitecore.Data.Items.Item
class.
You need to get Source
field value e.g. like this:
foreach ($field in $fields) {
Write-Host "Name: $($field.Name)"
Write-Host "Source: $($field._.Source.Value)"
Write-Host
}
1
This example is making use of a custom object SPE adds to the item. You can use_
orPSFields
to get typed properties.
– Michael West
Feb 15 at 16:25
add a comment |
There is no Source
property on Sitecore.Data.Items.Item
class.
You need to get Source
field value e.g. like this:
foreach ($field in $fields) {
Write-Host "Name: $($field.Name)"
Write-Host "Source: $($field._.Source.Value)"
Write-Host
}
There is no Source
property on Sitecore.Data.Items.Item
class.
You need to get Source
field value e.g. like this:
foreach ($field in $fields) {
Write-Host "Name: $($field.Name)"
Write-Host "Source: $($field._.Source.Value)"
Write-Host
}
answered Feb 15 at 15:26
Marek MusielakMarek Musielak
10.4k11136
10.4k11136
1
This example is making use of a custom object SPE adds to the item. You can use_
orPSFields
to get typed properties.
– Michael West
Feb 15 at 16:25
add a comment |
1
This example is making use of a custom object SPE adds to the item. You can use_
orPSFields
to get typed properties.
– Michael West
Feb 15 at 16:25
1
1
This example is making use of a custom object SPE adds to the item. You can use
_
or PSFields
to get typed properties.– Michael West
Feb 15 at 16:25
This example is making use of a custom object SPE adds to the item. You can use
_
or PSFields
to get typed properties.– Michael West
Feb 15 at 16:25
add a comment |
The issue is that the Source
field is of type Template Field Source
, which seems to not automatically emit a value if you simply access the field directly on the item ($field.Source
).
Instead, you must get the field and get the value from that field:
$field.Fields['Source'].Value
add a comment |
The issue is that the Source
field is of type Template Field Source
, which seems to not automatically emit a value if you simply access the field directly on the item ($field.Source
).
Instead, you must get the field and get the value from that field:
$field.Fields['Source'].Value
add a comment |
The issue is that the Source
field is of type Template Field Source
, which seems to not automatically emit a value if you simply access the field directly on the item ($field.Source
).
Instead, you must get the field and get the value from that field:
$field.Fields['Source'].Value
The issue is that the Source
field is of type Template Field Source
, which seems to not automatically emit a value if you simply access the field directly on the item ($field.Source
).
Instead, you must get the field and get the value from that field:
$field.Fields['Source'].Value
answered Feb 15 at 15:18
Dan SinclairDan Sinclair
1,954525
1,954525
add a comment |
add a comment |
Thanks for contributing an answer to Sitecore Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsitecore.stackexchange.com%2fquestions%2f16819%2fsitecore-powershell-extensions-not-returning-field-source-value%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown