Compartilhar via


"How to" guide

I was planning to write a pending blog post with different "how to" questions answered. Not limiting the post to any specific Microsoft product / technology , I will keep updating this one as and when I find time to spare. So then , lets get started....

How to check which Domain contoller the Current User is connected to ?

Start -> cmd -> SET LOGONSERVER

 

How to list all the SQL Server instances present on the local machine using SQLDMO ?

Create a new text file and paste following lines of VB code in that. Next save the file with .VBS extension and double click it. An output file will be generated listing all the SQL server instances on the host machine.

Option Explicit
On Error Resume Next

Dim sSQLServer
Dim oSQLDMO
Dim oInstances
Dim nCount
Const ForWriting = 2, ForAppending = 8
Dim fso, f
Dim sFile
Dim sHostname
Dim oNTInfo

sFile = "SQLInstances_" & Year(Date) &"_"& Month(Date) & "_" & Day(Date)&"_Log.txt"
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(sFile, ForAppending, True)

Set oNTInfo = CreateObject("WinNTSystemInfo")
sHostname = oNTInfo.ComputerName

sSQLServer = "localhost"
Set oSQLDMO = CreateObject("SQLDMO.SQLServer2")
Set oInstances = oSQLDMO.ListInstalledInstances(sSQLServer)

f.writeLine "* * * * * * * * * * * * * * * * * * * * *"
f.writeLine " Writing started at:" & Hour(Time) & "h" & Minute(Time) & "m" & Second(Time) & "s!"
f.writeLine " System Name=" & CStr(sHostname) & "!"
f.writeLine " SQL Server Name=" & CStr(sSQLServer) & "!" & vbCrLf

f.writeLine " Got oInstances.Count=" & CStr(oInstances.Count) & "!"
If Err.Number <> 0 Then
f.writeLine " >> Error occured!!! << "
f.writeLine " >> Please send this log file << "
f.writeLine " >> to the EMC Avamar Support Team! << "
Err.Clear
Else
For nCount = 1 To oInstances.Count
f.writeLine " " & CStr(nCount) & ".instance=" & CStr(oInstances.Item(nCount)) & "!"
Next
End If

f.writeLine vbCrLf & " Writing ended at:"& Hour(Time) & "h" & Minute(Time) & "m" & Second(Time) & "s!"
f.writeLine "* * * * * * * * * * * * * * * * * * * * *" & vbCrLf & vbCrLf

f.Close
Set oSQLDMO = Nothing
Set f = Nothing
Set fso = Nothing
Set oInstances = Nothing
Set oNTInfo = Nothing

 How to check if there are any duplicate SPN's in Windows Server 2008 ?

 setspn -X
 Here X will search for duplicate SPNs

 setspn -F
 Here F will perform the duplicate checking on forestwide level.