Posted By

michanne on 12/30/10


Tagged

Miscellaneous


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

michanne


Powershell snips


 / Published in: Windows PowerShell
 

Short Random lines of code mostly from Powershell.com

  1. #Build SQLCMD line for all files in the directory.
  2.  
  3. dir tables|foreach{$a = $_\3.Name;"r: Tables\$a"}>201106_Deploy.sql
  4.  
  5. #Generate random passwords
  6. -join ([Char[]]'abcdefgABCDEFG0123456&%$' | Get-Random -count 20)
  7.  
  8. #Generate a range of letters base on the ascii code (e.g. A: B:...)
  9. 65..90 | Foreach-Object { "$([char]$_):" }
  10.  
  11. <#Reading Text Files Fast - returns String#>
  12.  
  13. $a = [System.IO.File]::ReadAllText("$path\wkspace.csv")
  14.  
  15. <#Reading Text Files fast - returns Array
  16. Measure-command returns time to execute metadata#>
  17.  
  18. measure-command{[System.IO.File]::ReadAllText("$path\wkspace.csv")}

Report this snippet  

You need to login to post a comment.