Skip to content

Instantly share code, notes, and snippets.

@aburok
aburok / gist:c366d7cdb319b3a6252a
Created March 25, 2015 09:54
Get Directory Size
Get-ChildItem -Recurse | Measure-Object -Sum Length
OR
ls -r | measure -s Length
@aburok
aburok / gist:26fe3e13766d06337ca7
Created March 25, 2015 09:53
Get last n lines of file , powershell, tail
Get-Content "path/to/file" | Select-Object -Last 10
OR
gc "path/to/file" | select -Last 10
@aburok
aburok / gist:7665c0206d26e6b4dd89
Created March 25, 2015 09:53
Powershell search files and echo full path
Get-ChildItem "C:\" -Recurse
| Where-Object {$_.extension -eq ".txt" }
| ForEach-Object { Write-Host $_.FullName }
-- OR --
gci "C:\" -re
| ? { $_.extension -eq ".txt" }
| % { echo $_.FullName }
@aburok
aburok / gist:b0037c5e53b6ad915f10
Created March 25, 2015 09:52
powershell Get n biggest files from directory ( without directories )
Get-ChildItem -Recures -Include *
| Where-Object { -not $_.PSIsContainer }
| Sort-Object Length -descending
| Select-Object -First 10
| Select Name, Length
-- OR --
gci -re -in *
| ?{-not $_.PSIsContainer}
@aburok
aburok / gist:b29f2002c283dac0c61e
Created March 25, 2015 09:45
Adding block to content area programatically
GetBlocks(aboutPage.TopLeftContentBox)
.Select(block => new ContentAreaItem()
{
ContentLink = ((IContent)block).ContentLink
})
.ToList()
.ForEach(cai => aboutPage.AdditionalContent.Items.Add(cai));
_contentRepository.Save(aboutPage, SaveAction.Publish);