CSV

GNU/Linux ASCII Table in CSV/TXT format

Simple ASCII table in (formatted) text and available for download in CSV-format

Binary		Oct	Dec	Hex	Chr
0000 0000	000	0	00	NUL
0000 0001	001	1	01	SOH
0000 0010	002	2	02	STX
0000 0011	003	3	03	ETX
0000 0100	004	4	04	EOT
0000 0101	005	5	05	ENQ
0000 0110	006	6	06	ACK
0000 0111	007	7	07	BEL
0000 1000	010	8	08	BS
0000 1001	011	9	09	HT
0000 1010	012	10	0A	LF
0000 1011	013	11	0B	VT
0000 1100	014	12	0C	FF
0000 1101	015	13	0D	CR
0000 1110	016	14	0E	SO
0000 1111	017	15	0F	SI
0001 0000	020	16	10	DLE
0001 0001	021	17	11	DC1
0001 0010	022	18	12	DC2
0001 0011	023	19	13	DC3
0001 0100	024	20	14	DC4
0001 0101	025	21	15	NAK
0001 0110	026	22	16	SYN
0001 0111	027	23	17	ETB
0001 1000	030	24	18	CAN
0001 1001	031	25	19	EM
0001 1010	032	26	1A	SUB
0001 1011	033	27	1B	ESC
0001 1100	034	28	1C	FS
0001 1101	035	29	1D	GS
0001 1110	036	30	1E	RS
0001 1111	037	31	1F	US
0010 0000	040	32	20	 
0010 0001	041	33	21	!
0010 0010	042	34	22	"
0010 0011	043	35	23	#
0010 0100	044	36	24	$
0010 0101	045	37	25	%
0010 0110	046	38	26	&
0010 0111	047	39	27	'
0010 1000	050	40	28	(
0010 1001	051	41	29	)
0010 1010	052	42	2A	*
0010 1011	053	43	2B	+
0010 1100	054	44	2C	,
0010 1101	055	45	2D	-
0010 1110	056	46	2E	.
0010 1111	057	47	2F	/
0011 0000	060	48	30	0
0011 0001	061	49	31	1
0011 0010	062	50	32	2
0011 0011	063	51	33	3
0011 0100	064	52	34	4
0011 0101	065	53	35	5
0011 0110	066	54	36	6
0011 0111	067	55	37	7
0011 1000	070	56	38	8
0011 1001	071	57	39	9
0011 1010	072	58	3A	:
0011 1011	073	59	3B	;
0011 1100	074	60	3C	<
0011 1101	075	61	3D	=
0011 1110	076	62	3E	>
0011 1111	077	63	3F	?
0100 0000	100	64	40	@
0100 0001	101	65	41	A
0100 0010	102	66	42	B
0100 0011	103	67	43	C
0100 0100	104	68	44	D
0100 0101	105	69	45	E
0100 0110	106	70	46	F
0100 0111	107	71	47	G
0100 1000	110	72	48	H
0100 1001	111	73	49	I
0100 1010	112	74	4A	J
0100 1011	113	75	4B	K
0100 1100	114	76	4C	L
0100 1101	115	77	4D	M
0100 1110	116	78	4E	N
0100 1111	117	79	4F	O
0101 0000	120	80	50	P
0101 0001	121	81	51	Q
0101 0010	122	82	52	R
0101 0011	123	83	53	S
0101 0100	124	84	54	T
0101 0101	125	85	55	U
0101 0110	126	86	56	V
0101 0111	127	87	57	W
0101 1000	130	88	58	X
0101 1001	131	89	59	Y
0101 1010	132	90	5A	Z
0101 1011	133	91	5B	[
0101 1100	134	92	5C	\
0101 1101	135	93	5D	]
0101 1110	136	94	5E	^
0101 1111	137	95	5F	_
0110 0000	140	96	60	`
0110 0001	141	97	61	a
0110 0010	142	98	62	b
0110 0011	143	99	63	c
0110 0100	144	100	64	d
0110 0101	145	101	65	e
0110 0110	146	102	66	f
0110 0111	147	103	67	g
0110 1000	150	104	68	h
0110 1001	151	105	69	i
0110 1010	152	106	6A	j
0110 1011	153	107	6B	k
0110 1100	154	108	6C	l
0110 1101	155	109	6D	m
0110 1110	156	110	6E	n
0110 1111	157	111	6F	o
0111 0000	160	112	70	p
0111 0001	161	113	71	q
0111 0010	162	114	72	r
0111 0011	163	115	73	s
0111 0100	164	116	74	t
0111 0101	165	117	75	u
0111 0110	166	118	76	v
0111 0111	167	119	77	w
0111 1000	170	120	78	x
0111 1001	171	121	79	y
0111 1010	172	122	7A	z
0111 1011	173	123	7B	{
0111 1100	174	124	7C	|
0111 1101	175	125	7D	}
0111 1110	176	126	7E	~
0111 1111	177	127	7F	DEL

PowerShell Check Database-backup

This next script can be used to check if Full and Transaction Log backups are made within the last two days. Databases are read from a CSV file. I use a slightly modified version which reads databases from a registration database.

# ********************************************************************
# Scriptnaam: CHECKBACKUP.PS1
# Geschreven_door: Tim van Kooten Niekerk
# Versie: 20110811A
# Info: Check if backup is made within last two days...
# ********************************************************************

# Global config settings...
[string]$sServerInstanceFile = ".ServerInstance.csv"
[string]$sSMTPServer1 = "smtp-server-name"
[string]$sToAddress1 = "email-adsress"

# Global objects...
$oNETIP = [System.Net.NetworkInformation.IPGlobalProperties]::GetIPGlobalProperties()

# Register Snapins...
$oPSSnapinRegResult = PSSnapin SqlServerCmdletSnapin* -registered
if ($oPSSnapinRegResult) {
  $oPSSnapinResult = PSSnapin $oPSSnapinRegResult.Name
  if (-not $oPSSnapinResult) { 
    Add-PSSnapin $oPSSnapinRegResult.Name
  }
} else {
  break
}
  
# Functions and Procedures...
function fSendMail([string]$sSMTPSrvrName, [string]$sFrom, [string]$sTo, [string]$sSubject, [string]$sBody, [string]$sAttFileName) {
  if (($sSMTPSrvrName) -and ($sFrom) -and ($sTo) -and $sSubject) {
  
    # Declare mail objects...
    $oMessage = new-object Net.Mail.MailMessage
    $oSMTP = new-object Net.Mail.SmtpClient($sSMTPSrvrName)

    # Pass values to object...
    $oMessage.From = $sFrom
    $oMessage.To.Add($sTo)
    $oMessage.Subject = $sSubject
    if ($sBody) { $oMessage.Body = $sBody }

    # Add attachment...
    if ($sAttFileName) {
      $oAttachment = new-object Net.Mail.Attachment($sAttFileName)
      $oMessage.Attachments.Add($oAttachment)
    }

    $oSMTP.Send($oMessage)
    if ($? -eq "True") {
      return "INFO: Email has been sent."
    } else {
      return "ERROR: Error sending e-mail."
    }

  } else {
    return "ERROR: Argument(s) missing. [fSendMail `"SMTPServerName`" `"From`" `"To`" `"Subject`" (`"Body`") (`"AttachFileName`")]"
  }
}

function fSQLCmd([string]$sInstance, [string]$sQuery, [string]$sDatabase) {
  if ($sDatabase) {
    [string]$sQuery = "Invoke-SqlCmd -ServerInstance " + $sInstance + " -Database " + $sDatabase + " -QueryTimeout 30 -Query `"" `
                               + $sQuery + "`" ; if (`$? -eq `$false) { @{`"ERROR0`" = `$error[0]}; @{`"ERROR1`" = `$error[1]} }" 
  } else {
    [string]$sQuery = "Invoke-SqlCmd -ServerInstance " + $sInstance + " -QueryTimeout 30 -Query `"" + $sQuery + "`" ; `
                               if (`$? -eq `$false) { @{`"ERROR0`" = `$error[0]}; @{`"ERROR1`" = `$error[1]} }" 
  }
  return Invoke-Expression $sQuery
}

# Start Main script...
[int]$iCounter = 0
Import-Csv $($sServerInstanceFile) -header ("instance", "checkfull", "checktl") | foreach {
  # Skip header...
  if (($iCounter -ne 0) -and ($_.instance)) {
    $oResult1 = $null
    $oResult2 = $null
    # Run Queries on servers...
    if ($_.checkfull -eq 1) {
      [string]$sQuery1 = "/* ##### Begin T-SQL Query... ##### */ `
      SELECT sys.databases.name AS NoRecentFullBackup `
      FROM sys.databases `
      WHERE sys.databases.name NOT IN `
      (SELECT DISTINCT sys.databases.name from sys.databases `
      INNER JOIN msdb..backupset ON sys.databases.name = msdb..backupset.database_name `
      WHERE ((msdb..backupset.type = 'D' OR msdb..backupset.type = 'I') `
      AND msdb..backupset.is_copy_only = 0 `
      AND msdb..backupset.backup_start_date > (GetDate() -2))) `
      AND sys.databases.state = 0 `
      AND sys.databases.name  'tempdb' `
      /* ##### Einde T-SQL Query... ##### */"
      # Forceer in een object zodat we altijd kunnen tellen...
      [Object[]]($oResult1) = fSQLCmd $($_.instance) $sQuery1 "master"
    }


    if ($_.checktl -eq 1) {
      [string]$sQuery2 = "/* ##### Begin T-SQL Query... ##### */ `
      SELECT sys.databases.name AS NoRecentTLBackup `
      FROM sys.databases `
      WHERE sys.databases.name NOT IN `
      (SELECT DISTINCT sys.databases.name from sys.databases `
      INNER JOIN msdb..backupset ON sys.databases.name = msdb..backupset.database_name `
      WHERE (msdb..backupset.type = 'L' AND msdb..backupset.backup_start_date > (GetDate() -2))) `
      AND sys.databases.recovery_model != 3 and sys.databases.state = 0 `
      /* ##### Einde T-SQL Query... ##### */"
      # Forceer in een object zodat we altijd kunnen tellen...
      [Object[]]($oResult2) = fSQLCmd $($_.instance) $sQuery2 "master"
    }

    # Zodra er rows worden geteld een e-mail samenstellen...
    if (($oResult1.Count -gt 0) -or ($oResult2.Count -gt 0)) {
      $oResult1 = $oResult1 | Out-String
      $oResult2 = $oResult2 | Out-String
      [string]$sFromAddress1 = "noreply@" + $oNETIP.HostName + "." + $oNETIP.DomainName
      [string]$sBody1 = $oResult1 + $oResult2
      [string]$sSubject1 = $($_.instance.Replace("", "_")) + ":Database backup older than 2 days..."
      fSendMail $sSMTPServer1 $sFromAddress1 $sToAddress1 $sSubject1 $sBody1
    }
  }
  $iCounter++
}
# ********************************************************************

CSV File format:

instance,checkfull,checktl
SERVERA,1,1
SERVERBINS1,1,1
SERVERC,1,1

VBS Convert HTML Tables

Visual Basic script to convert HTML to CSV or TEXT using the Excel.Application object.

'****************************************************************************************
'bestandsnaam: ConvertTable2X.vbs
'geschreven_door: Tim van Kooten Niekerk
'versie: 17:38 15-4-2010
'Converteer html tabellen naar CSV of TEXT m.b.v. het Excel object
'****************************************************************************************

' Global variable and const declarations
option explicit
'on error resume next
dim oEXC, oArg
const xlCSV=6
const xlTXT=21

' Global objectdeclarations
set oArg = WScript.Arguments 
set oEXC = CreateObject("Excel.Application")

' Functie inlezen argumenten van de commandline (0-?)
function fReadArgument(vArgNumber)
  On Error Resume Next
  fReadArgument = oArg(vArgNumber)
end function

' Convert2X function...
function fTable2X(sHTMLFile, sCSVFile, sFileType)
  if (sHTMLFile ‹› "") and (sCSVFile ‹› "") then
    dim oWB
    set oWB =  oEXC.Workbooks.Open (sHTMLFile)
    'oEXC.Visible = True
    oEXC.Application.DisplayAlerts = False
    oEXC.ActiveWorkbook.SaveAs sCSVFile,  sFileType
    oEXC.ActiveWorkbook.Close False 
    oEXC.Application.DisplayAlerts = True

    ' Opschonen
    Set oWB =  Nothing
  end if
end function

' Start programma...
if fReadArgument("0") ‹› "" and fReadArgument("1") ‹› ""  and fReadArgument("2") ‹› "" then
  fTable2X fReadArgument("0"), fReadArgument("1"), fReadArgument("2")
else
  MsgBox ("Een of meerdere argumenten ontbreken..." & vbCrLf & vbCrLf & "Gebruik: convertTable2X   " & vbCrLf & "(filetypenum: 6=CSV, 21=TXT)")
end if

' Opschonen
set oArg = Nothing
set oEXC = Nothing

 

PowerShell batch nslookup

Article is written in the Dutch language… 

Onderstaande PowerShell script zoekt ip-adressen bij hostnamen uit een CSV-bestand en schrijft deze waarden weg in een text-bestand. De eerste regel van het CSV-bestand moet de kolomnamen bevatten. Het script kijkt naar de kolom met de naam “Hostname”.

# *****************************************************************************
# Scriptnaam: NSLOOKUP2.PS1
# Geschreven_door: Tim van Kooten Niekerk
# Versie: 2009.10.16.01
# Info: Dit script zoekt IP-adressen bij hostnamen vanuit een CSV-bestand.
# Info: De resultaten worden uitgevoerd naar bestand: "IPadressen.txt".
# Info: De 1e regel van het CSV-bestand moet kolomnamen bevatten. 
# INfo: Het script kijkt alleen naar de kolom "Hostname".
# *****************************************************************************

$vDNSServerIP = "[server-ip-address]"
$vImportCSVFile = "HostNames.csv"
$vOutputTXTFile = "IPadressen.txt"

$aImportCSV1 = import-csv $vImportCSVFile
foreach ($vRow in $aImportCSV1 ) { 
  $vNSLookup = nslookup $($vRow.Hostname) $($vDNSServerIP) | `
               select-string -NotMatch -Pattern $($VDNSServerIP)
  $VNSLookupIP = $vNSLookup | select-string -Pattern "Address"
  $VNSLookupName = $vNSLookup | select-string -Pattern "Name"

  # Stel een regel samen t.b.v. uitvoer bestand...
  "Question:   " + $vRow.HostName + "	" + `
  $vNSLookupName.Line + "	" + `
  $vNSLookupIP.Line | `
  Out-File -Append -Filepath $vOutputTXTFile
}