PowerShell – sorting files by datestamp for SQL backup/restore

# Do-SPSQLbackupRestore.ps1# usage:# DO-SQLBackupRestore <Backup|Restore> [<SQL instance>] [<XMLfilename]>#[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SqlServer.SMO”) | Out-Null[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SqlServer.SmoExtended”) | Out-Null[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SqlServer.ConnectionInfo”) | Out-Null[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SqlServer.SmoEnum”) | Out-Null Function DO-SQLBackupRestore {  param ([string] $strSQLaction=”Backup”, [string] $strSQLServerInstance=”(local)”, [string] $DataBasesXML=”C:\BKP\BKP-SQLdatabases.xml”)   $SQLserver = New-Object (“Microsoft.SqlServer.Management.Smo.Server”) $strSQLServerInstance  $xml = [XML] (get-content $DataBasesXML)   ## dbName_yyyyMMddHHmmss.BAK  $stamp = “yyyyMMddHHmmss”  if ($strSQLaction.ToUpper() -eq “BACKUP”) {  DoBackupSQL $SQLserver $xml }  else { if…

3

PowerShell – decode an F5 BIG-IP cookie

# Decode-BigIPCookie.ps1# usage:# Decode-BigIPCookie “375537930.544.0000” function Decode-Cookie {  param ([string] $ByteArrayCookie)  ### F5 itself for the formula: http://support.f5.com/kb/en-us/solutions/public/6000/900/sol6917.html ### $poolcookie=”375537930.544.0000″ ###  if ($ByteArrayCookie -match ‘^(\d+)\.(\d+)\.0000$’) {   $ipEncoded   = [int64] $matches[1]   $portEncoded = [int64] $matches[2]    #  convert ipEnc to Hexadecimal   $ipEncodedHex = “{0:X8}” -f $ipEncoded   #  then split into an array of four    $ByteArray=@()   $ipEncodedHex -split…

1