Skip to content

Commit

Permalink
Nick's blog added to sample scripts: http://www.techphoria414.com/Blo…
Browse files Browse the repository at this point in the history
…g/2012/September/Use_Sitecore_Powershell_to_Find_Templates_with_Layout

Text results shows the text properly formatted with colors now.
Output.ToString no longer adds additional line terminations.
  • Loading branch information
AdamNaj committed Sep 2, 2013
1 parent de9833d commit f63f6f0
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
----item----
version: 1
id: {7CC5F576-FA33-4773-B94E-22DC9CEEAB8D}
database: master
path: /sitecore/system/Modules/PowerShell/Script Library/Examples/Content interrogation/Find templates using a layout
parent: {9BCCA568-A261-4681-85EB-C74D513736EF}
name: Find templates using a layout
master: {00000000-0000-0000-0000-000000000000}
template: {DD22F1B3-BD87-4DB2-9E7D-F7A496888D43}
templatekey: PowerShell Script

----version----
language: en
version: 1
revision: 6ce9c51f-cdcf-4079-91d2-ada751dee5b6

----field----
field: {B1A94FF0-6897-47C0-9C51-AA6ACB80B1F0}
name: Script
key: script
content-length: 967

<#
Based on Blog by @Techphoria414 - Nick Wesselman
http://www.techphoria414.com/Blog/2012/September/Use_Sitecore_Powershell_to_Find_Templates_with_Layout
#>

$layout = get-item "master:\layout\Layouts\Sample Layout\"
$result = Read-Variable -Parameters `
@{ Name = "layout"; Title="Layout"; Root="/sitecore/layout/Layouts/"; Tooltip="Layout you want to find."} `
-Description "This report will analyse the templates and show you all the templates that use the Layout you choose in this dialog" `
-Title "Layout Usage" -Width 500 -Height 400 `
-OkButtonName "Find" -CancelButtonName "Abort"

if($result -ne "ok")
{
Exit
}

$linkDatabase = [Sitecore.Globals]::LinkDatabase
$links = $linkDatabase.GetReferrers($layout)
$links | foreach-object { if ($_.GetSourceItem() -and $_.GetSourceItem().Paths.Path.ToLower().StartsWith("/sitecore/templates")) { write-host $_.GetSourceItem().Paths.Path } }
Show-Result -Text -Width 800 -Height 700
Close-Window
----field----
field: {25BED78C-4957-4165-998A-CA1B52F67497}
name: __Created
key: __created
content-length: 15

20130902T101027
----field----
field: {8CDC337E-A112-42FB-BBB4-4143751E123F}
name: __Revision
key: __revision
content-length: 36

6ce9c51f-cdcf-4079-91d2-ada751dee5b6
----field----
field: {D9CF14B1-FA16-4BA6-9288-E8A174D4D522}
name: __Updated
key: __updated
content-length: 34

20130902T101932:635137139728065625
----field----
field: {BADD9CF9-53E0-4D0C-BCC0-2D784C282F6A}
name: __Updated by
key: __updated by
content-length: 14

sitecore\admin
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,48 @@ templatekey: PowerShell Script
----version----
language: en
version: 1
revision: 900607d8-1fcf-4f31-8c06-0a0e1ecd860c
revision: 7f306535-4324-4a18-a63c-c9cb8e2c0ac4

----field----
field: {B1A94FF0-6897-47C0-9C51-AA6ACB80B1F0}
name: Script
key: script
content-length: 5145
content-length: 6182

$package = get-package "PowerShell Console.xml"
$package = new-package "Sitecore PowerShell Extensions";
$package.Sources.Clear();

$psVersion = 2.3
$package.Metadata.Author = "Adam Najmanowicz - Cognifide, Michael West";
$package.Metadata.Publisher = "Cognifide Limited";
$package.Metadata.Publisher = "Cognifide Limited";
$package.Metadata.Version = "2.3";
$package.Metadata.Readme = 'This module provides 2 immediately usable interfaces
The "PowerShell Console" available from the "Sitecore"
menu and the "PowerShell ISE" available from the
"Developer Tools" sub-menu.

PowerShell ISE comes with a sample script and
Script Library for you to experiment with. Enjoy!

Most Recent Releases:
- 2.3 (1 September 2013)
Release Notes: http://bit.ly/ScPs23Iss
- 2.2 (30 July 2013)
Release Notes: http://bit.ly/ScPs22Iss
- 2.1 (15 July 2013)
Release Notes: http://bit.ly/ScPs21Iss

Please report any problems in our issue tracker:
http://bit.ly/ScPsIss

Thank you for using Sitecore PowerShell Extensions.

Copyright (c) 2010-2013 Adam Najmanowicz - Cognifide
Copyright (c) 2013 Michael West

http://www.cognifide.com/
http://blog.najmanowicz.com/
http://michaellwest.blogspot.com/'

# Item templates
$source = Get-Item 'master:\templates\Modules\PowerShell Console' | New-ItemSource -Name "Master Item Templates" -InstallMode Overwrite -MergeMode Merge
Expand Down Expand Up @@ -102,8 +132,8 @@ $package.Sources.Add($source);
$source = Get-ChildItem -Path "$AppPath\sitecore\Shell\Applications\Powershell\*" -Recurse -File | New-ExplicitFileSource -Name "Application Files"
$package.Sources.Add($source);

Export-Package -Project $package -Path "Sitecore PowerShell Extensions-$psVersion.xml"
Export-Package -Project $package -Path "Sitecore PowerShell Extensions-$psVersion.zip" -Zip
Export-Package -Project $package -Path "$($package.Name)-$($package.Metadata.Version).xml"
Export-Package -Project $package -Path "$($package.Name)-$($package.Metadata.Version).zip" -Zip
----field----
field: {25BED78C-4957-4165-998A-CA1B52F67497}
name: __Created
Expand All @@ -117,14 +147,14 @@ name: __Revision
key: __revision
content-length: 36

900607d8-1fcf-4f31-8c06-0a0e1ecd860c
7f306535-4324-4a18-a63c-c9cb8e2c0ac4
----field----
field: {D9CF14B1-FA16-4BA6-9288-E8A174D4D522}
name: __Updated
key: __updated
content-length: 34

20130820T150951:635126081912913281
20130901T224455:635136722956690937
----field----
field: {BADD9CF9-53E0-4D0C-BCC0-2D784C282F6A}
name: __Updated by
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ protected override void ProcessRecord()
ScriptSession session = SessionState.PSVariable.Get("ScriptSession").Value as ScriptSession;
if (session!= null)
{
var message = new ShowResultsMessage(session.Output.ToString(), WidthString, HeightString);
var message = new ShowResultsMessage(session.Output.ToHtml(), WidthString, HeightString);

JobContext.MessageQueue.PutMessage(message);
JobContext.Flush();
Expand Down
4 changes: 0 additions & 4 deletions PowerShellIntegrations/Host/OutputLine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,6 @@ public void GetTerminalLine(StringBuilder output)
public void GetPlainTextLine(StringBuilder output)
{
output.Append(Text);
if (Terminated)
{
output.Append("\n");
}
}

public void GetLine(StringBuilder temp, string stringFormat)
Expand Down

0 comments on commit f63f6f0

Please sign in to comment.