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
# SPE 4.0 has upgraded the New-UsingBlock function to a cmdlet | |
Import-Function New-UsingBlock | |
$stringWriterDefinition = @" | |
using System.IO; | |
using System.Text; | |
public sealed class StringWriterWithEncoding : StringWriter | |
{ | |
private readonly Encoding encoding; |
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 Get-LockedChildItem { | |
<# | |
.SYNOPSIS | |
Gets the locked item at the specified location. | |
.PARAMETER Path | |
Specifies a path to search for locked items. The default location is the current directory (.). | |
.PARAMETER LockedBy | |
Specifies the the owner account locked on the item. |
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 Project="$(MSBuildExtensionsPath)\HedgehogDevelopment\SitecoreProject\v9.0\HedgehogDevelopment.SitecoreProject.targets" /> | |
<ItemGroup> | |
<AssembliesPath Include="..\SomethingAwesome.Web\bin\SomethingAwesome.Web.dll" /> | |
</ItemGroup> | |
<Target Name="BeforeSitecoreBuild"> | |
<GetAssemblyIdentity AssemblyFiles="@(AssembliesPath)"> | |
<Output TaskParameter="Assemblies" ItemName="AssemblyVersion" /> | |
</GetAssemblyIdentity> | |
<CreateProperty Value="%(AssemblyVersion.Version)"> | |
<Output TaskParameter="Value" PropertyName="PackageVersion" /> |
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
# Get all the enabled users. | |
$users = Get-ADUser -Filter { Enabled -eq $true } -Properties EmployeeId | |
# Collect all the ids and format them to 7 characters. | |
$ids = @{}; $users | ForEach-Object { if($_.EmployeeId) { $ids[("{0:D7}" -f [int]$_.EmployeeId)] += 1 } } | |
$filteredUsers = $users | Where-Object { if($_.EmployeeId) { $ids[("{0:D7}" -f [int]$_.EmployeeId)] -gt 1 } } | |
$filteredUsers | Select-Object -Property SamAccountName, EmployeeId | |
$filteredUsers | Export-Csv -Path "C:\temp\DuplicateEmployeeId-$((Get-Date).ToString('yyyyMMddThhmmss')).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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>Down for Maintenance</title> | |
</head> | |
<body> | |
<div> </div> | |
<div id="wrapper"> | |
<div id="page"> | |
<div id="content"> |
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
Windows Registry Editor Version 5.00 | |
[HKEY_CLASSES_ROOT\pngfile\shell\Copy image to clipboard] | |
@="Copy image to clipboard" | |
[HKEY_CLASSES_ROOT\pngfile\shell\Copy image to clipboard\command] | |
@="C:\\\\Windows\\\\system32\\\\WindowsPowerShell\\\\v1.0\\\\powershell.exe -Command \"Add-Type -AssemblyName 'PresentationFramework','PresentationCore';[System.Windows.Clipboard]::SetImage((New-Object System.Windows.Media.Imaging.BitmapImage ([System.Uri]'%1')))\"" | |
[HKEY_CLASSES_ROOT\jpegfile\shell\Copy image to clipboard] | |
@="Copy image to clipboard" |
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
<# | |
Total number of Sublayouts in your Sitecore instance along with referrer pages and caching parameters | |
#> | |
$selectedItem = Get-Item -Path "master:\layout" | |
$result = Read-Variable -Parameters ` | |
@{ Name = "selectedItem"; Title = "Please select the path to query"; Root="/sitecore/layout/"} -Width 500 -Height 280 -OkButtonName "Proceed" -CancelButtonName "Abort" | |
if($result -ne "ok") { | |
Close-Window |
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 | |
Reports on all the content items missing a translation in Sitecore. | |
#> | |
$languageNames = Get-ChildItem -Path "master:\" -ID ([Sitecore.ItemIDs]::LanguageRoot) | | |
Select-Object -ExpandProperty Name | |
$groups = Get-ChildItem -Path "master:\content\" -Recurse -Language * | Group-Object -Property Name | Where-Object { $_.Count -lt $languageNames.Count } |
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
#region Setup | |
# The module should reside in $env:PSModulePath | |
Import-Module -Name SPE -Force | |
# Use Get-Help to see examples | |
$props = @{ | |
Session = (New-ScriptSession -Username "admin" -Password "b" -ConnectionUri "http://console") | |
Verbose = $true |
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 SPE | |
$session = New-ScriptSession -Username "admin" -Password "b" -ConnectionUri "http://remotesitecore" | |
$jobId = Invoke-RemoteScript -Session $session -ScriptBlock { | |
foreach($num in 0..10) { | |
$key = -join ((65..90) + (97..122) | Get-Random -Count 7 | % {[char]$_}) | |
New-User -Identity "TestUser$($key)" -Enabled -Password "b" | Out-Null | |
} | |
} -AsJob |