Skip to content

Instantly share code, notes, and snippets.

@AdamNaj
Last active February 24, 2016 16:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AdamNaj/1b46da24ed8ed6b84593 to your computer and use it in GitHub Desktop.
Save AdamNaj/1b46da24ed8ed6b84593 to your computer and use it in GitHub Desktop.
SUGCON Presentation
$days = 7;
Get-ChildItem master:\content\home -Recurse |
? { $_."__updated" -gt (Get-Date).AddDays(-$days) } |
Format-Table -Property ID, Name, "__updated", "__updated by"
$days = 7;
Read-Variable -Parameters @{ Name="days"; Title="Number of days"} -Title "Pointy haired report" | Out-Null
Get-ChildItem master:\content\home -Recurse |
? { $_."__updated" -gt (Get-Date).AddDays(-$days) } |
Format-Table -Property ID, Name, "__updated", "__updated by"
$days = 7;
Read-Variable -Parameters @{ Name="days"; Title="Number of days"} -Title "Pointy haired report" | Out-Null
Get-ChildItem master:\content\home -Recurse |
? { $_."__updated" -gt (Get-Date).AddDays(-$days) } |
Show-ListView -Property ID, Name, "__updated", "__updated by"
$days = 7;
Read-Variable -Parameters @{ Name="days"; Title="Number of days"} -Title "Pointy haired report" | Out-Null
Find-Item -Criteria @{Filter="DescendantOf"; Value=(Get-Item master:\content\home)} -Index sitecore_master_index |
? { $_.Updated -gt (Get-Date).AddDays(-$days) } | Initialize-Item |
Show-ListView -Property ID, Name, "__updated", "__updated by"
# Shows the export functionality with automatic variables
$days = 7;
Read-Variable -Parameters @{ Name="days"; Title="Number of days"} -Title "Pointy haired report" | Out-Null
Find-Item -Criteria @{Filter="DescendantOf"; Value=(Get-Item master:\content\home)} -Index sitecore_master_index |
? { $_.Updated -gt (Get-Date).AddDays(-$days) } | Initialize-Item |
Select-Object -Property ID, Name, "__updated", "__updated by" |
Export-Csv -Path "$($SitecoreDataFolder)\PointyHairedReport-$([datetime]::Now.ToString("yyyyMMdd")).csv"
$head = '<style>'+
'body{font-family:"Lucida Sans Unicode", "Lucida Grande", Sans-Serif; text-align:left;}'+
'h1 {width:100%;font-family: "Skolar Bold", Palatino, Cambria, "Droid Serif", Georgia, "Times New Roman", Times, serif; font-size: 28px;}'+
'p {width:100%;font-family: "Proxima Nova Regular", "Helvetica Neue", Calibri, "Droid Sans", Helvetica, Arial, sans-serif; font-size: 18px}'+
'table {font-size:12px; border-collapse:collapse; border:1px solid #69c; margin:20px;}'+
'th{font-weight:normal; font-size:14px; color:#039; border-bottom:1px dashed #69c; padding:12px 17px;}'+
'td{color:#668;padding:7px 17px;border-bottom: 1px dashed #d8e8ff;}'+
'tbody tr:hover td{color:#339;background:#f0f0ff;}'+
'</style>'
$body = "<h1>Pointy report $($item)</h1>"
if ($HttpContext -ne $null){
$HttpContext.Response.ContentType = "text/html";
}
if ($days -eq $null){
$days = 7;
}
Find-Item -Criteria @{Filter="DescendantOf"; Value=(Get-Item master:\content\home)} -Index sitecore_master_index |
? { $_.Updated -gt (Get-Date).AddDays(-$days) } | Initialize-Item |
Select-Object -Property ID, Name, "__updated", "__updated by" |
ConvertTo-Html -head $head -body $body | % { [System.Web.HttpUtility]::HtmlDecode($_) }
Import-Module -Name SPE
$session = New-ScriptSession -Username admin -Password b -ConnectionUri http://sitecore8
Invoke-RemoteScript -Session $session -ScriptBlock {
Get-Item -Path "master:\content\home\"
}
function Install-CustomPackage {
param(
[int]$Size = 2
)
Start-Sleep -Seconds $size
"Install complete."
}
Import-Module -Name SPE
if(!$session) {
$session = New-ScriptSession -Username admin -Password b -ConnectionUri http://sitecore8
}
Invoke-RemoteScript -Session $session -ScriptBlock {
Import-Function -Name Install-CustomPackage
Install-CustomPackage -Size 5
}
Import-Module -Name SPE
if(!$session) {
$session = New-ScriptSession -Username admin -Password b -ConnectionUri http://sitecore8
}
Invoke-RemoteScript -Session $session -ScriptBlock {
Start-ScriptSession -Id "SUGCON" -ScriptBlock {
Import-Function -Name Install-CustomPackage
Install-CustomPackage 5
}
}
Import-Module -Name SPE
if(!$session) {
$session = New-ScriptSession -Username admin -Password b -ConnectionUri http://sitecore8
}
Invoke-RemoteScript -Session $session -ScriptBlock {
Start-ScriptSession -Id "SUGCON" -ScriptBlock {
Import-Function -Name Install-CustomPackage
Install-CustomPackage 5
}
}
$complete = $false
while(!$complete) {
$complete = Invoke-RemoteScript -Session $session -ScriptBlock {
(Get-ScriptSession -Id "SUGCON").State -ne "Busy"
}
Write-Host "." -NoNewline
Start-Sleep -Milliseconds 500
}
Invoke-RemoteScript -Session $session -ScriptBlock {
Receive-ScriptSession -Id "SUGCON"
}
$colors = "Cyan", "Gray","Green","Magenta","Red","White","Yellow"
for($i=0; $i -lt 10; $i++){
if($i -eq 5){
Set-PSBreakpoint -Script "$PSCommandPath" -Line 15
}
$color = "";
foreach($j in 1..10){
$color = "$($colors[(Get-Random -Maximum $colors.Length)])";
Write-Host ("{0:D3} " -f ($i*10+$j)) -ForegroundColor "$color" -no
Write-Progress -Activity "Line $i, column $j" -PercentComplete (($i*10+$j)/4.2)
Start-Sleep -Milliseconds 10
}
Write-Host " "
Get-PSBreakpoint | Remove-PSBreakpoint
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment