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 ActiveDirectory | |
Set-ADUser -Identity "Michael.West" -Replace @{"thumbnailPhoto" = [byte[]](Get-Content -Path "michael.jpg" -Encoding Byte)} |
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 | |
Archives old log files int zip format to a separate archive directory. | |
.NOTES | |
Michael West | |
#> | |
<# | |
Load the function Compress-Archive. The Get-Item command supports a dynamic parameter |
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
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, | |
// INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. | |
using System.Text; | |
using Sitecore.SharedSource.Reflection; | |
using Sitecore.Pipelines.GetAboutInformation; | |
namespace Sitecore.SharedSource.Pipelines | |
{ | |
public class ApplicationDetails |
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
$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
<# | |
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 |
OlderNewer