This file contains hidden or 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-RDPUsers ($computers) { | |
process{ | |
foreach($computer in $computers) { | |
try { | |
$quser = quser /server:$computer 2>&1 | Select-Object -Skip 1 | |
foreach($user in $quser) { | |
$line = [regex]::split($user.Trim(), '\s{2,}') | |
$o = if ($line[2] -eq 'Disc') { 0 } else { 1 } |
This file contains hidden or 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
# Quick Draft to Share | |
class Node { | |
[String] $name | |
[Boolean] $isImported = $false | |
[System.Collections.Generic.List[Node]] $edges | |
hidden static [System.Collections.Generic.List[Node]] $resolved = [System.Collections.Generic.List[Node]]::new() | |
hidden static [System.Collections.Generic.List[Node]] $unresolved = [System.Collections.Generic.List[Node]]::new() | |
This file contains hidden or 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-ColoredSyntax ($command) | |
{ | |
Write-Host ("{0} " -f (get-help $command).name) -NoNewline -ForegroundColor White | |
$syn = ((get-help $command).syntax.syntaxitem.parameter) | select name, @{Name='type'; Expression = {$_.type.name}}, required | |
$width = 170 | |
if ($host.UI.RawUI.WindowSize.Width -notin ("", $null)) { | |
$width = $host.UI.RawUI.WindowSize.Width | |
} | |
$curLength = 0 |
This file contains hidden or 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 space($pc) | |
{ | |
Get-WmiObject Win32_LogicalDisk -ComputerName $pc | | |
Where-Object {$_.DriveType -eq 3} | | |
Select-Object DeviceID, VolumeName, ` | |
@{n="Size"; e={[math]::round($_.Size / 1GB, 1)}}, ` | |
@{n="FreeSpace"; e={[math]::round($_.FreeSpace / 1GB, 1)}}, ` | |
@{n="PercentFree"; e={[math]::round($_.FreeSpace / $_.Size * 100.0, 1)}} | | |
Format-Table | |
} |
This file contains hidden or 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
$stack = New-Object System.Collections.Stack | |
function I { | |
if($args[$args.Count - 1]){ | |
$stack.push($args[$args.Count - 1]) | |
} | |
} | |
function UH! { | |
if($stack.Count -ge 2){ |
This file contains hidden or 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
# Generate a custom error without C# | |
function New-ErrorRecord ([string] $ErrorID, [string] $Message, [HashTable] $Custom) | |
{ | |
$errorCategory = [Management.Automation.ErrorCategory]::InvalidResult | |
$exception = New-Object Exception $Message | |
$errorRecord = New-Object Management.Automation.ErrorRecord $exception, $ErrorID, $errorCategory, $Custom | |
return $errorRecord | |
} |
This file contains hidden or 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 export | |
{ | |
try | |
{ | |
$s = ($args[0]).Split("=", 2) | |
if($s.Count -ne 2) | |
{ | |
throw "more finesse please." | |
} |
This file contains hidden or 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
# Add nix-like touch command | |
function touch | |
{ | |
$file = $args[0] | |
if($file -eq $null) | |
{ | |
throw "No filename supplied" | |
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
# Browsers | |
cinst googlechrome | |
# IDE and Extensions | |
cinst visualstudiocode | |
cinst vscode-powershell | |
cinst sublimetext3 | |
cinst SublimeText3.PackageControl | |
cinst vim |
NewerOlder