This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
Moves items to the recycle bin which are more than 30 days old and have no references. | |
.NOTES | |
Michael West | |
#> | |
filter Skip-MissingReference { | |
$linkDb = [Sitecore.Globals]::LinkDatabase |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function New-UsingBlock { | |
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory = $true)] | |
[IDisposable] | |
$InputObject, | |
[Parameter(Mandatory = $true)] | |
[ScriptBlock] | |
$ScriptBlock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# List of template ids to exclude from the count. | |
$templateIds = @( | |
"{29FD19B5-6F81-4829-B725-9C4279DA13CE}", | |
"{C3C9ED41-B476-49A9-B50C-FF8901665EA0}", | |
"{5A905A62-4898-44CE-96BA-EB3432BAAD91}" | |
) | |
@(Get-Item -Path master:\content\home) + @(Get-ChildItem -Path master:\content\home -Recurse) | | |
Where-Object { $templateIds -notcontains $_.TemplateId } | | |
Select-Object -Property Name, TemplateId | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://www.layerworks.com/blog/2015/4/17/sitecore-powershell-script-examples | |
$VerbosePreference = "continue" | |
$path = "master:/sitecore/layout/renderings" | |
Write-Log "Get all renderings and determine if caching is enabled." | |
Get-ChildItem -Path $path -Recurse | | |
Where-Object { $_.TemplateName -ne "Rendering Folder" } | | |
Format-Table -AutoSize -Property Name, ItemPath, ID, @{"Name"="Cacheable";"Expression"={$_.Cacheable -eq "1"}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
Runs a clean up for each database. | |
.NOTES | |
Michael West | |
#> | |
foreach($database in Get-Database) { | |
if(!$database.ReadOnly) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$paths = @("C:\inetpub\wwwroot\Console\Website\App_Config\Include\*","C:\inetpub\wwwroot\Demo\Website\App_Config\Include\*") | |
$patterns = @("Sitecore.Analytics*.config", "Sitecore.ExperienceAnalytics*.config") | |
$paths | Get-ChildItem -Include $patterns -Recurse | Rename-Item -NewName { $PSItem.Name + ".disabled" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Import-Module -Name ActiveDirectory | |
Get-ADUser -Identity michael.west -Properties memberof | | |
Select-Object -ExpandProperty memberof | | |
ForEach-Object { [pscustomobject]@{"MemberOf"=$_ }} | | |
Export-Csv -Path C:\Temp\groups.csv -NoTypeInformation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
Adapted from the Package History module found here: | |
https://marketplace.sitecore.net/en/Modules/PackageHistory.aspx | |
#> | |
function Get-PackageHistory { | |
$packageHistoryPath = "/sitecore/system/Packages/Installation history" | |
$packageRegistrationTemplateId = "{22A11D20-5F1D-4216-BF3F-18C016F1F98E}" | |
$coreDb = Get-Database -Name "core" | |
$historyItem = $coreDb.GetItem($packageHistoryPath) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The following example remotely executes a script in Sitecore using a reusable session. | |
$session = New-ScriptSession -Username admin -Password b -ConnectionUri http://remotesitecore | |
Invoke-RemoteScript -Session $session -ScriptBlock { Get-User -id admin } | |
Name Domain IsAdministrator IsAuthenticated | |
---- ------ --------------- --------------- | |
sitecore\admin sitecore True False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The following downloads an item from the media library in the master db and dynamically detects the file extension. | |
$session = New-ScriptSession -Username admin -Password b -ConnectionUri http://remotesitecore | |
Receive-MediaItem -Session $session -Path "/sitecore/media library/Images/Icons/accuracy" -Destination C:\Images\ -Force |