Skip to content

Instantly share code, notes, and snippets.

Adam Najmanowicz AdamNaj

Block or report user

Report or block AdamNaj

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Add-ItemAccess.ps1
function Add-ItemAccess{
[CmdletBinding()]
param(
[Parameter(Position=0, Mandatory=$true, ValueFromPipeline=$true)]
[ValidateNotNullOrEmpty()]
[Sitecore.Data.Items.Item]$item,
[Parameter(Position=1, Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string]$roleName)
@AdamNaj
AdamNaj / ExportAccountsInAPackage.ps1
Created May 25, 2015
Export Roles and users in a package
View ExportAccountsInAPackage.ps1
$package = (New-Package -Name "Security")
$source = Get-Role -Filter * | New-SecuritySource -Name "All Roles"
$package.Sources.Add($source)
$source = Get-User -Filter * | New-SecuritySource -Name "All Users"
$package.Sources.Add($source)
$source = New-SecuritySource -Filter sitecore\* -Name "Sitecore Roles and users" -AccountType Unknown
$package.Sources.Add($source)
Export-Package "Security" -Project $package
@AdamNaj
AdamNaj / Find-CmdletsWithLanguageParem.ps1
Created Jun 15, 2015
Find SPE cmdletsthat have Language Parameter
View Find-CmdletsWithLanguageParem.ps1
Get-Command -CommandType Cmdlet | ? { $_.DLL -match "Cognifide"} | ? { $_.Parameters.ContainsKey("Language")} | sort Name
@AdamNaj
AdamNaj / RV-Item-WithNoItemDefined.ps1
Created Jul 8, 2015
Read-Variable with no item pre-defined
View RV-Item-WithNoItemDefined.ps1
Read-Variable -Parameters `
@{ Name = "item"; Title="Start Item"; Root="/sitecore/content/"; Editor="item"},
@{ Name = "items"; Title="Bunch of Templates";
Source="DataSource=/sitecore/templates&DatabaseName=master&IncludeTemplatesForDisplay=Node,Folder,Template,Template Folder&IncludeTemplatesForSelection=Template";
editor="treelist"},
@{ Name = "items2"; Title="Bunch of Templates";
Source="DataSource=/sitecore/templates&DatabaseName=master&IncludeTemplatesForDisplay=Node,Folder,Template,Template Folder&IncludeTemplatesForSelection=Template";
editor="multilist"; Height="230px"},
@{ Name = "items3"; Title="Pick One Template";
Source="DataSource=/sitecore/templates&DatabaseName=master&IncludeTemplatesForDisplay=Node,Folder,Template,Template Folder&IncludeTemplatesForSelection=Template";
@AdamNaj
AdamNaj / SpeRenderPercentageExample.ps1
Created Jul 25, 2015
Render Percentages report example
View SpeRenderPercentageExample.ps1
Import-Function Render-ReportField
1..100 | Show-ListView -Property @{Name="Value"; Expression={$_}}, @{Name="Percentage"; Expression={ Render-PercentValue $_}} `
-Title "percentages demo." `
-PageSize 200
View RichReport.ps1
#Show-ListView - with rich renderers
Import-Function Render-ReportField
$script = Get-Item "master:\system\Modules\PowerShell\Script Library\Authorable Reports\Functions\Show-SearchResultDetails"
$index="sitecore_master_index"
Get-ChildItem master:\ | Show-ListView -Property `
ProviderPath, @{Label="Display Name"; Expression={ $_.DisplayName }},
HasChildren, TemplateName,
@{Label="Random Percent Test"; Expression={ Render-PercentValue (Get-Random -minimum 1 -maximum 100) }},
@{Label="Thumbnail"; Expression={ Render-ItemField $_ __thumbnail }},
@{Label="Index Fields"; Expression={ Render-ScriptInvoker $script @{index=$index; itemId="$($_.Uri)"} "Show Index Fields" } }
View LiveProgressTest.ps1
gci master:\ -rec
$colors = "Cyan", "Gray","Green","Magenta","Red","White","Yellow"
foreach($i in 1..20){
foreach($j in 1..20){
Write-Host ("{0:D3} " -f ($i*20+$j)) -ForegroundColor "$($colors[(Get-Random -Maximum $colors.Length)])" -no
Write-Progress -Activity "Line $i, column $j" -PercentComplete (($i*20+$j)/4.2)
Start-Sleep -Milliseconds 10
}
View Retrieve-SitecorePackage (failed).ps1
# unfortunately does not work, because - #1 - does not really retrieve the file, #2 has problems with logging out
Import-Module -Name SPE
function Retrieve-SitecorePackage($session, $instance, $PackageName, $Destination){
$loginUri = "$instance/sitecore/login"
$login = Invoke-WebRequest -Uri $loginUri -SessionVariable webSession
$form = $login.Forms[0]
$form.Fields["__EVENTTARGET"] = ""
$form.Fields["UserName"] = $session.Username
View Retrieve-SitecorePackage.ps1
Import-Module -Name SPE
function Retrieve-SitecorePackage($session, $instance, $PackageName, $Destination){
Invoke-WebRequest "$instance/-/script/file/package/?path=$PackageName&user=$($session.Username)&password=$($session.Password)" -OutFile $Destination -WebSession $webSession
}
$instance = "http://sitecore8"
$session = New-ScriptSession -Username admin -Password b -ConnectionUri $instance
$packageName = "package.zip"
@AdamNaj
AdamNaj / Receive-Zip.ps1
Created Sep 15, 2015
Upload and Unzip dialog
View Receive-Zip.ps1
# replace "target folder" with the path in the media library you want to put your files in.
Receive-File -ParentItem (gi "master:\media library\target folder") -AdvancedDialog
You can’t perform that action at this time.