Wednesday, 28 April 2010

Windows : Audit recent RDP logins

If the login/logoff is being audited in group policy (default?)
  • Event log id 682 in the security log shows all log on events including
    client name and ip
  • Event log id 683 in the security log shows all log off events including client name and ip


Monday, 26 April 2010

Excel: Worksheet splitter vb

Sub SalesmanToSheet()
Dim lastrow As Long, LastCol As Integer, i As Long, iStart As Long, iEnd As Long
Dim ws As Worksheet
Application.ScreenUpdating = False
With ActiveSheet
lastrow = .Cells(Rows.Count, "A").End(xlUp).Row
LastCol = .Cells(1, Columns.Count).End(xlToLeft).Column
.Range(.Cells(2, 1), Cells(lastrow, LastCol)).Sort Key1:=Range("A2"), Order1:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
iStart = 2
For i = 2 To lastrow
If .Range("A" & i).Value <> .Range("A" & i + 1).Value Then
iEnd = i
Sheets.Add after:=Sheets(Sheets.Count)
Set ws = ActiveSheet
On Error Resume Next
ws.Name = .Range("A" & iStart).Value
On Error GoTo 0
ws.Range(Cells(1, 1), Cells(1, LastCol)).Value = .Range(.Cells(1, 1), .Cells(1, LastCol)).Value
With ws.Rows(1)
.HorizontalAlignment = xlCenter
With .Font
.ColorIndex = 5
.Bold = True
End With
End With
.Range(.Cells(iStart, 1), .Cells(iEnd, LastCol)).Copy Destination:=ws.Range("A2")
iStart = iEnd + 1
End If
Next i
End With
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub

Thursday, 22 April 2010

WIndows : Stop Robocopy trying forever

robocopy srcDir destDir /R:2 /W:10 /MIR'
retry and wait between attempts - default is 1million and 30 seconds

SQL Server: Listing sessions in 2000

SELECT DB_NAME(dbid) as 'Database Name',
COUNT(dbid) as 'Total Connections'
FROM master.dbo.sysprocesses WITH (nolock)
WHERE dbid > 0
GROUP BY dbid

SELECT DB_NAME(dbid) as 'Database Name', a.*
FROM master.dbo.sysprocesses a WITH (nolock)
WHERE dbid > 0

Thursday, 11 March 2010

SQLServer : Object sizes Report

USE DEALHUB_ARCH1

select 'Database Name: ', db_name()
set nocount on
if exists(select name from tempdb..sysobjects where name='##tmp')
drop table ##tmp
create table ##tmp(nam varchar(50), rows int, res varchar(15),data varchar(15),ind_sze varchar(15),unsed varchar(15))
go

declare @tblname varchar(50)
declare tblname CURSOR for select name from sysobjects where xtype='U'
open tblname
Fetch next from tblname into @tblname
WHILE @@FETCH_STATUS = 0
BEGIN
insert into ##tmp

exec sp_spaceused @tblname
  FETCH NEXT FROM tblname INTO @tblname

END
CLOSE tblname

deallocate tblname
go

select nam Table_Name,rows Total_Rows,res Total_Table_Size,data Data_size,ind_sze Index_Size,unsed Unused_Space from ##tmp
drop table ##tmp



Monday, 8 March 2010

Audacity : Recording from a sound card in Vista

  • Download and install Virtual Audio Cable (not freeware) - confirm when prompted
  • Taskbar -> Go to the playback devices (right-click the speaker icon) - Select the 'Playback' tab.
  • There will be a new option named 'Line 1' or 'VAC 1' etc
  • Make that 'Line 1' Default (button)
  • Close all programs (specially programs that have sound - itunes, realplayer, windows media player)
  • Then, run the program Audio Repeater (Included in the VAC install use start->all programs)
  • Set 'Wave in' to 'Line 1'
  • Set 'Wave out' to "SPEAKER" (or your computer's original default selection)
  • After this, click 'Start' tab below.
  • Then, turn on any music on the computer you should hear the sound from your speaker.
  • Right-click the speaker icon on your taskbar-> recording devices -> 'Recording' tab -> make 'Line 1' Default
  • Run Audacity -> Edit -> Preferences -> Audio I/O tab -> See 'Recording' and make 'device' into 'Line 1'


Friday, 5 March 2010

Oracle Dataguard : dgmgrl - various commands

<b>Start dgmgrl
</b>
  • export ORACLE_SID=dbdg; . oraenv; dgmgrl
  • sys/<password>
<b>Check the configuration status<br /></b>
  • SHOW CONFIGURATION;
  • SHOW DATABASE VERBOSE 'North_Sales'
  • SHOW DATABASE 'North_Sales';
  • SHOW DATABASE 'North_Sales' 'StatusReport';
  • SHOW DATABASE 'North_Sales' 'InconsistentProperties';
  • SHOW DATABASE 'North_Sales' 'InconsistentLogXptProps';
Change properties
  • EDIT DATABASE 'DR_Sales' SET PROPERTY 'LogArchiveFormat'='log_%t_%s_%r_%d.arc';
  • EDIT DATABASE 'DR_Sales' SET STATE='READ-ONLY';
<b>Create/enable configuration<br /></b>
  • CREATE CONFIGURATION 'DRSolution' AS PRIMARY DATABASE IS 'North_Sales' CONNECT IDENTIFIER IS North_Sales.foo.com;
  • ADD DATABASE 'DR_Sales' AS CONNECT IDENTIFIER IS DR_Sales.foo.com MAINTAINED AS PHYSICAL;
  • SHOW CONFIGURATION;
  • ENABLE CONFIGURATION;
<b>Stop transmit of dbs from primary <br /></b>
  • EDIT DATABASE North_Sales SET STATE=LOG-TRANSPORT-OFF
<b>Temporarily stop broker managing and monitoring a standby database.<br /></b>
Switchover
  • SWITCHOVER TO DR_Sales;
  • SHOW CONFIGURATION;
<b>Manual Failover<br /></b>
  • FAILOVER TO "DR_Sales";
  • SHOW CONFIGURATION;