-
-
Save happysysadm/166dab44b89973b46a7c1e2dff07dce4 to your computer and use it in GitHub Desktop.
PowerShell Oneliner Contest 2016 - working solutions
This file contains 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
$oneliner = {([char[]](71..89)|?{!(gdr $_)2>0}|sort{[guid]::newguid()})[0]+':'} | |
#Posted by Sam Seitz to Happy SysAdm at October 25, 2016 at 8:02 AM | |
$oneliner = {([char[]](71..89)|?{!(gdr($_)2>0)}|sort{[guid]::newguid()})[0]+":"} | |
#Posted by Rick Humes to Happy SysAdm at November 3, 2016 at 11:01 AM | |
$oneliner = {((71..89|%{"$([char]$_):"|?{-not(gi $_ -EA Ig)}})|sort{[guid]::newguid()})[0]} | |
#Posted by Marco Schmid to Happy SysAdm at October 25, 2016 at 4:55 AM | |
$oneliner = {([char[]](71..89)|?{$_-notin(gdr -P "f*").Name}|sort{[guid]::NewGuid()})[0]+':'} | |
#Posted by cruz3r to Happy SysAdm at October 26, 2016 at 2:12 PM | |
$oneliner = {($l=[char[]](71..89)|?{$_-notin(gdr|% N*)})[[random]::new().Next($l.count)]+":"} | |
#Posted by ????? to Happy SysAdm at October 28, 2016 at 4:18 PM | |
$oneliner = {[char[]](71..89)|%{$_+':'}|?{(!(ls($_)-EA 0))}|sort{[guid]::NewGuid()}|select -F 1} | |
#Posted by Anders Aspnäs to Happy SysAdm at November 1, 2016 at 1:09 AM | |
$oneliner = {,([char[]](71..89)|?{$_-NotIn(gdr).Name})|%{$_[[Random]::new().Next(0,$_.count)]+':'}} | |
#Posted by Christophe K. to Happy SysAdm at October 29, 2016 at 6:08 AM | |
$oneliner = {,((ls -Pa Function:[a-z]: -N) -match "['G-Y']")|%{$_[[Random]::new().Next(0,$_.count)]}} | |
#Posted by Micky Balladelli to Happy SysAdm at October 24, 2016 at 2:05 PM | |
$oneliner = {[char[]](71..89)|sort{[guid]::NewGuid()}|%{if(!(ls($_+':')-EA Ignore)){$_+':'}}|select -F 1} | |
#Posted by Anders Aspnäs to Happy SysAdm at October 27, 2016 at 4:35 AM | |
$oneliner = {[char](,(71..89|?{!(gi "$([char]$_):" -ea Si) })|%{$_[[Random]::new().Next($_.count)]})+':'} | |
#Posted by Micky Balladelli to Happy SysAdm at October 28, 2016 at 12:55 PM | |
$oneliner = {do{$a="$([char]([random]::new().Next(71,90))):"}while(gwmi win32_logicaldisk|? deviceid -eq $a)$a} | |
#Posted by Anthony to Happy SysAdm at November 3, 2016 at 2:45 PM | |
$oneliner = {do{$a="$([char]([random]::new().Next(71,90))):"}while(gwmi win32_logicaldisk -F "deviceid='$a'")$a} | |
#Posted by Anthony to Happy SysAdm at November 3, 2016 at 2:36 PM | |
$oneliner = {begin{$x=71..89|?{!(ls -ea 0 "$([char]$_):")}}end{"$([char]$x[[random]::new().Next(0,$x.count)]):"}} | |
#Posted by Olof Blomqvist to Happy SysAdm at October 26, 2016 at 1:08 PM | |
$oneliner = {([char[]](71..89)|?{!(gdr $_ -ea 0)})[([random]::new()).next($(([char[]](71..89)|?{!(gdr $_ -ea 0)})).count)]+":"} | |
#Posted by Ben Himsel to Happy SysAdm at October 25, 2016 at 1:34 PM | |
$oneliner = {(ls function:[g-y]:|%{$_|select -ov x|%{try{sl $x.name -ea st}catch{write @{[guid]::NewGuid()=$x.name}}}}|sort Keys)[0].values} | |
#Posted by Sam Hays to Happy SysAdm at October 31, 2016 at 4:25 PM | |
$oneliner = {71..89|%{if(!(ls "$([char]$_):" -ea 4)){@{([char]$_+":")=[Guid]::NewGuid().GetHashCode()}.GetEnumerator()}}|sort value|select -exp name -f 1} | |
#Posted by mario arizzi to Happy SysAdm at October 24, 2016 at 10:13 AM | |
$oneliner = {(71..89|%{[char]$_+":"}|%{if($_-NotIn(gwmi win32_logicaldisk).DeviceID){$_}})[[System.Random]::new().Next(0,(71..89|%{[char]$_+":"}|%{if($_-NotIn(gwmi win32_logicaldisk).DeviceID){$_}}).length)]} | |
#Posted by Nexxicon to Happy SysAdm at October 24, 2016 at 12:57 PM |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment