Friday, July 15, 2016

How to find Stored Procedures in your Database

In case you are in a situation where you are looking for a stored procedure in SQL but don't remember the name or forgot the parameters used. You are on the right blog to get you those data in seconds :)

Execute below query in your Database to get a list of all Stored Procedures

select * from sysobjects where id in
(select id from syscomments where text like '%exec%')
order by [name]

Execute below query to get the parameters for a particular stored procedure

select t1.[name] as [SP_name],t2.[name] as [Parameter_name],
t3.[name] as [Type],t2.[Length],t2.colorder as [Param_order]
from sysobjects t1
inner join syscolumns t2 on t1.[id]=t2.[id]
inner join systypes t3 on t2.xtype=t3.xtype
where t1.[name]='name of the stored procedure'
order by [Param_order]

Execute below query to get more detailed info on stored procedures and their parameters.

SELECT SCHEMA_NAME(SCHEMA_ID) AS [Schema],
SO.name AS [ObjectName],
SO.Type_Desc AS [ObjectType (UDF/SP)],
P.parameter_id AS [ParameterID],
P.name AS [ParameterName],
TYPE_NAME(P.user_type_id) AS [ParameterDataType],
P.max_length AS [ParameterMaxBytes],
P.is_output AS [IsOutPutParameter]
FROM sys.objects AS SO
INNER JOIN sys.parameters AS P
ON SO.OBJECT_ID = P.OBJECT_ID
WHERE SO.OBJECT_ID IN ( SELECT OBJECT_ID
FROM sys.objects
WHERE TYPE IN ('P','FN'))
ORDER BY [Schema], SO.name, P.parameter_id

Happy learning!




Friday, November 7, 2014

What is Office 365 ?



A Web-based version of Microsoft's Office suite of enterprise-grade applications. Office 365 is delivered to users through the cloud and includes Exchange Online for email, SharePoint Online for collaboration, Lync Online for unified communications, and a suite of Office Web Apps, Web-based versions of the traditional Microsoft Office  suite of applications.

Know more about it here :
http://products.office.com/en-us/business/explore-office-365-for-business

 

Monday, January 6, 2014

VBScript : Check Ping Status and Last boot time

Do you want to check status of multiple servers ? Do you want to know whether it is online ? or Do you want to check when was it rebooted? And on top of that you have 100+ servers to check... here is the solution.

Below is a VBScript which gives you Ping Status and last boot time for a list of servers.


Set objFSO = CreateObject("Scripting.FileSystemObject")
'Servers.txt is the input file. Save the server names in this file.
Set objTextFile = objFSO.OpenTextFile("C:\temp\Servers.txt",1,True)
'Result.txt is the output file
Set objOutputFile = objFSO.OpenTextFile("C:\temp\Result.txt",2,True)

Do While objTextFile.AtEndOfLine <> True
  strComputer = objTextFile.ReadLine


On Error resume Next
Set oWMI = GetObject("winmgmts:\\.\root\cimv2")
Set oPing = oWMI.Get("Win32_PingStatus.Address='"& strComputer & "'")

If oPing.StatusCode = 0 Then
   Set objWMIService = GetObject("winmgmts:" _
 & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") 

Set colOperatingSystems = objWMIService.ExecQuery _
    ("Select * from Win32_OperatingSystem")

For Each objOS in colOperatingSystems
    dtmBootup = objOS.LastBootUpTime
    Exit For

Next

WMIDateStringToDate = CDate(Mid(dtmBootup, 5, 2) & "/" & _
        Mid(dtmBootup, 7, 2) & "/" & Left(dtmBootup, 4) )
WMIDateStringToTime = CDate(Mid(dtmBootup, 9, 2) & ":" & _
        Mid(dtmBootup, 11, 2) & ":" & Mid(dtmBootup,13, 2))

objOutputFile.WriteLine( strComputer & vbTab & WMIDateStringToDate & " " & WMIDateStringToTime & vbTab & "Able to Ping")

Else

objOutputFile.WriteLine( strComputer & vbTab & "Not Able to Ping")

End If

Set colOperatingSystems = nothing
Set objWMIService = Nothing
Set oWMI = Nothing
Set oPing = Nothing

Loop

Wscript.Echo "Done"

Note :

  • The script can be used to retrieve the values from servers in the same domain.
  • Save the script as a .vbs file and double click the same to run.
  • Servers.txt will store the list of servers for which output is required.
  • Result.txtis created which stored the output.
 Please write your queries in comment section.

VBScript to get Total Space details of drives on Multiple Servers

Hello everyone.. i am sharing one of my very first script used to get size details of drives on multiple servers in a domain. Hope it helps.

Dim strExcelPath, objExcel, objSheet, a, b, c
Const xlExcel7 = 39
 ' Spreadsheet file to be created.Result.xls will store the output.
strExcelPath = "c:\temp\Result.xls"

Set fso = CreateObject("Scripting.FileSystemObject")
' Server.txt is the input file for the script under C:\temp. Save server names in this file.
Set objInputFile = fso.OpenTextFile("c:\temp\Server.txt",1,True)


Set objExcel = CreateObject("Excel.Application")
If (Err.Number <> 0) Then
    On Error Goto 0
    Wscript.Echo "Excel application not found."
    Wscript.Quit
End If
On Error Goto 0
 ' Create a new workbook.
objExcel.Visible = True
objExcel.Workbooks.Add
' Bind to worksheet.
Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)
objSheet.Name = "Server Details"
' Format the spreadsheet.
objSheet.Range("A1:Z1").Font.Bold = True
intRow = 2
 
objExcel.Cells(1, 1).Value = "Hostname"
objExcel.Cells(1, 2).Value = "C:"
objExcel.Cells(1, 3).Value = "E:"
objExcel.Cells(1, 4).Value = "F:"
objExcel.Cells(1, 5).Value = "G:"
objExcel.Cells(1, 6).Value = "H:"
objExcel.Cells(1, 7).Value = "M:"
objExcel.Cells(1, 8).Value = "Q:"
objExcel.Cells(1, 9).Value = "T:"
objExcel.Cells(1, 10).Value ="I:"
 
Do While objInputFile.AtEndOfLine <> True

 strComputer = objInputFile.ReadLine
  objExcel.Cells(intRow, 1).Value = strComputer

 On Error resume Next
Set oWMI = GetObject("winmgmts:\\.\root\cimv2")
Set oPing = oWMI.Get("Win32_PingStatus.Address='"& strComputer & "'")

If oPing.StatusCode = 0 Then
 
 
  Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
 ("SELECT * FROM Win32_LogicalDisk")
   
     For Each objItem In colItems

        a = objItem.DeviceID
        b =  objItem.Size /1048576\1024 + 1
   
     Select Case a
         Case "C:"
             objExcel.Cells(intRow, 2).Value = b
         Case "E:"
             objExcel.Cells(intRow, 3).Value = b
         Case "F:"
             objExcel.Cells(intRow, 4).Value = b
         Case "G:"
             objExcel.Cells(intRow, 5).Value = b
         Case "H:"
             objExcel.Cells(intRow, 6).Value = b
         Case "M:"
             objExcel.Cells(intRow, 7).Value = b
         Case "Q:"
             objExcel.Cells(intRow, 8).Value = b
         Case "T:"
             objExcel.Cells(intRow, 9).Value = b
         Case "I:"
             objExcel.Cells(intRow, 10).Value = b
     End Select
   
     
Next
intRow = intRow + 1
End If

Set objWMIService = Nothing
Set colItems = Nothing
Set objItem = Nothing


 Loop

' Save the spreadsheet and close the workbook.
 ' Specify Excel7 File Format.
objExcel.ActiveWorkbook.SaveAs strExcelPath, xlExcel7
objExcel.ActiveWorkbook.Close
 ' Quit Excel.
objExcel.Application.Quit
 ' Clean Up
Set objSheet = Nothing
Set objExcel = Nothing
Wscript.Echo "Done"


Note :
  • The script can be used to retrieve the values from servers in the same domain.
  • Save the script as a .vbs file and double click the same to run.
  • Server.txt will store the list of servers for which output is required.
  • Result.xls is created which stored the output.
 Please write your queries in comment section.

MSIEXEC



Microsoft Windows Installer (Windows 7/2008).
Syntax
      MSIEXEC /Option RequiredParameter [OptionalParameter]

Install Options
   Install or configure a product:
      MSIEXEC /package Product.msi
      MSIEXEC /i Product.msi

   Administrative install, Install a product on the network:
      MSIEXEC /a Product.msi

   Advertise a product to all users:
      MSIEXEC /j m Product.msi [/t TransformList] [/g LanguageID]

   Advertise a product to current user:
      MSIEXEC /j u Product.msi [/t TransformList] [/g LanguageID]

   Uninstall the product:
      MSIEXEC /uninstall Product.msi
      MSIEXEC /x Product.msi
      MSIEXEC /uninstall ProductCode
      MSIEXEC /x ProductCode

Display Options

   Quiet mode, no user interaction
      /quiet

   Unattended mode - progress bar only
      /passive

   Set user interface level: None
      /qn

   Set user interface level: Basic UI
      /qb

   Set user interface level: Reduced UI
      /qr

   Set user interface level: Full UI (default)
      /qf

   Help information
      /help
               
Restart Options
   Do not restart after the installation is complete:
      /norestart

   Prompt the user for restart if necessary:
      /promptrestart

   Always restart the computer after installation:
      /forcerestart
            
Logging Options
   /le Logfile  Log All error messages
   /lw Logfile  Log Non-fatal warnings
   /li Logfile  Log Status messages
   /la Logfile  Log Start up of actions
   /lr Logfile  Log Action-specific records
   /lu Logfile  Log User requests
   /lc Logfile  Log Initial (UI) parameters
   /lm Logfile  Log Out-of-memory or fatal exit information
   /lo Logfile  Log Out-of-disk-space messages
   /lp Logfile  Log Terminal properties
   /lv Logfile  Log Verbose output
   /lx Logfile  Log Extra debugging information

   /l* Logfile  Log all information, except for v and x options
   /log Logfile Equivalent of /l*

   /l+ Logfile  Append to an existing log file.
   /l! Logfile  Flush each line to the log.

Update Options
   Apply update(s)
      /update [;Update2.msp]

   Remove update(s) for a product:
      /uninstall [;Update2.msp] /package
               
Repair Options - Repair a previously installed product
   /fp          Repair/fix - replace missing files
   /fo          Repair/fix - replace Older files(default)
   /fe          Repair/fix - replace older or Equal date files
   /fd          Repair/fix - replace Different version files
   /fc          Repair/fix - replace files based on Checksum differences
   /fa          Repair/fix - replace All files
   /fu          Repair/fix - rewrite HKCU registry(default)
   /fm          Repair/fix - rewrite HKLM registry(default)
   /fs          Repair/fix - recreate shortcuts(default)
   /fv          Repair/fix - rewrite local cache from source

Set Public Properties
        [PROPERTY=PropertyValue]
Windows installer (and msiexec) have been updated with each major release of Windows (from 2000 to XP to 2008 R2) Windows Installer redistributables are available at the Microsoft Download Center.
Registry Keys:
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
Product codes - the ProductCode for each application is a GUID that can be retrieved with a WMI query in VBScript or PowerShell, Get-WmiObject Win32_Product will return the IdentifyingNumber which is the Product code:
PS C:\> gwmi Win32_Product -Filter "Name LIKE 'Paint.net v3%'"
Do not use the domain controller SYSVOL folder as a Windows Installer installation point, doing so may result in the following error when you attempt to run the Windows Installer (.msi) package:
This installation package could not be opened. Verify that the package exists and that you can access it, or contact the application vendor to verify that this is a valid Windows Installer package.
This is because the SYSVOL folder is created with the SHI1005_FLAGS_RESTRICT_EXCLUSIVE_OPENS attribute, which prevents it from being exclusively locked by Windows Installer. Having locked files on a SYSVOL will create Active Directory directory service synchronization problems.
Examples:
Install:
msiexec /i "C:\Install\ss64app.msi"

UnInstall:
msiexec /uninstall "{5AFF6499-63BA-4A36-83B2-8D256404AC3D}" /log "C:\install\ss64app.txt"
or remotely with psexec
psexec \\$workstation -s msiexec /uninstall "{5AFF6499-63BA-4A36-83B2-8D256404AC3D}" /log "C:\install\ss64app.txt"

CHKDSK Utility


If you're encountering persistent errors and need to run the CHKDSK utility in attempt to recover or fix any data or installation errors, simply follow these steps:
Note that running the CHKDSK utility can take up to several hours, so ensure you are able to leave your computer scanning for a large amount of time before attempting the following.

Windows 8 Users

  • Starting from the Desktop, hold down the Windows key and press E to open Windows Explorer.
  • Right-click the hard drive and select Properties.
  • Select the Tools tab.
  • Click the "Check" button under "Error checking"
  • Click the "Scan drive" button.
  • Click the "Schedule disk check" option and reboot.
  • After CHKDSK has finished running, try to start up and run your game to see if the issue was corrected.
Windows 7 Users
  • Hold down the Windows key and press E to open Windows Explorer.
  • Right-click the hard drive and select Properties.
  • Select the Tools tab.
  • Click the "Check now" button under "Error checking"
  • Check both boxes under "Check disk options"
  • Click the "Start" button.
  • Click the "Schedule disk check" option then reboot.
  • After CHKDSK has finished running, try to start up and run your game to see if the issue was corrected.
 CHKDSK can fix Error Events with id 55.


What is an event ID 55? Let’s start by looking at the error:

Event Type: Error
Event Source: NTFS
Event ID: 55
Description:
The file system structure on disk is corrupt and unusable. Please run the chkdsk utility on the volume "Drive_letter:"


Explanation
The file system structure on the volume listed in the message might be corrupt because of one or more of the following reasons:
  • The disk might have bad sectors.
  • I/O requests issued by the file system to the disk subsystem might not have been completed successfully.
   
User Action
Check the state of the file system and repair it if necessary.
To check the state of the file system
  1. Click Start, click Run, and then, in the Open box, type
    cmd
  2. To determine whether the volume is corrupt, at the command prompt, type
    chkntfs Drive:

    • If the message “Drive_letter: is dirty” is displayed, the volume is corrupt. In this case, repair the file system.
    • If the message “Drive_letter: is not dirty” is displayed, the volume is not corrupt and no further action is required.
To repair the file system
  1. Save any unsaved data and close any open programs.
  2. Restart the computer.
    The volume is automatically checked and repaired when you restart the computer.
Alternatively, you can run the Chkdsk tool from the command prompt without shutting down the computer first.
  1. Click Start, click Run, and then type
    cmd
  2. At the command prompt, type

  3. chkdsk /XDrive:
    Chkdsk runs and automatically repairs the volume.
If the following message appears, type Y.
“Cannot lock current drive. Chkdsk cannot run because the volume is in use by another process. Would you like to schedule this volume to be checked the next time the system restarts?”
The next time the computer is started, Chkdsk will automatically run.
If the NTFS 55 message appears regularly, for example daily or weekly, run Chkdsk using the /R command-line option. This option allows Chkdsk to locate bad sectors on the hard disk.








 

Tuesday, October 22, 2013

Useful Windows Command


How many users are logged on/connected to a server?

Sometimes we may need to know how many users are logged on to a (file) server, like maybe when there is a performance degradation.
At the server's console itself, with native commands only:
 NET SESSION | FIND /C "\\"
Remotely, with the help of SysInternals' PSTools:
 PSEXEC \\servername NET SESSION | FIND /C "\\"
By replacing FIND /C "\\" by FIND "\\" (removing the /C switch) you'll get a list of logged on users instead of just the number of users.

Who is logged on to a computer?

We often need to know who is currently logged on to a remote computer.
With native Windows (up to and including XP) commands only:
 NBTSTAT -a remotecomputer | FIND "<03>" | FIND /I /V "remotecomputer"
The first name in the list usually is the logged on user (try playing with the NET NAME command to learn more about the names displayed by NBTSTAT).
This is the fastest way to find the logged on user name, and the results that you do get are correct, but NBTSTAT won't always return a user name, even when a user is logged on.
Using WMIC (Windows XP Professional and later):
 WMIC /Node:remotecomputer ComputerSystem Get UserName
This is arguably the most reliable (native) command to find out who is logged on.
With the help of SysInternals' PSTools:
 PSLOGGEDON -L \\remotecomputer
or:
 PSEXEC \\remotecomputer NET CONFIG WORKSTATION | FIND /I " name "
or:
 PSEXEC \\remotecomputer NET NAME
or for Windows XP only:
 PSEXEC \\remotecomputer NETSH DIAG SHOW COMPUTER /V | FIND /i "username"
Using REG.EXE (Windows 2000 and later):
 FOR /F %%A IN ('REG Query \\remotecomputer\HKU ˆ| FINDSTR /R /B /C:"HKEY_USERS\\S-1-5-[0-9][0-9]-[0-9-]*$"') DO (
  FOR /F "tokens=3 delims=\" %%B IN ('REG Query "\\remotecomputer\%%A\Volatile Environment"') DO (
   SET LoggedinUser=%%B
  )
 )
or for Windows 7:
 FOR /F %%A IN ('REG Query \\remotecomputer\HKU /K /F "S-1-5-21-" ˆ| FINDSTR /R /B /C:"HKEY_USERS\\S-1-5-[0-9][0-9]-[0-9-]*$"') DO (') DO (
  FOR /F "tokens=2*" %%B IN ('REG Query "\\remotecomputer\%%~A\Volatile Environment" /V "UserName" ˆ| FIND /V ":"') DO (
   SET LoggedinUser=%%C
  )
 )
NETSH and WMIC are for XP or later, and are the most reliable of all commands shown here.
WMIC requires WMI enabled remote computers and Windows XP on the administrator's computer; NETSH requires Windows XP on the local and remote computers.
PSLOGGEDON is a more accurate solution than NBTSTAT, but it will return the last logged on user if no one is currently logged on.
The NET and NBTSTAT commands show more or less identical results, but the NBTSTAT command is much faster.
The REG command is accurate, but may need to be modified depending on the version used.
More information on REG versions can be found on my REG Query page.
For Windows NT 4 and 2000: use NBTSTAT (fast, but it won't always return the user name!), and only switch to REG if NBTSTAT doesn't return a user name (modify the REG command for Windows NT 4).
For Windows XP and later: if you want to search lots of computers for logged on users, I recommend you try NBTSTAT first (fast, but it won't always return the user name!), and only switch to NETSH, REG or WMIC (accurate) if NBTSTAT doesn't return a user name.
Credits: Jiří Janyška (WMIC command) and Matthew W. Helton (NETSH command).

What is this collegue's login name?

My collegues often forget to mention their logon account name when calling the helpdesk, and the helpdesk doesn't always ask either. I suppose they expect me to know all 1500+ accounts by heart.
With (native) Windows Server 2003 commands only:
 DSQUERY USER -name *lastname* | DSGET USER -samid -display
Note: Windows Server 2003's "DSTools" will work fine in Windows 2000 and XP too, when copied.
Keep in mind, however, that some Windows Server 2003 Active Directory functionality is not available in Windows 2000 Active Directories.

What is the full name for this login name?

With the native NET command:
 NET USER loginname /DOMAIN | FIND /I " name "
With (native) Windows Server 2003 commands:
 DSQUERY USER -samid *loginname* | DSGET USER -samid -display
Note: The NET command may seem more universal, because it requires neither Active Directory nor Windows Server 2003 commands, but it is language dependent!
For non-English Windows you may need to modify FIND's search string.

What groups is this user a member of?

In Windows NT 4 and later, users usually are members of global groups. These global groups in turn are members of (domain) local groups. Access permissions are given to (domain) local groups.
To check if a user has access to a resource, we need to check group membership recursively.
With (native) Windows Server 2003 commands:
 DSQUERY USER -samid loginname | DSGET USER -memberof -expand

What permissions does a user have on this directory?

One could use the previous command to check what permissions a user has on a certain directory.
However, sometimes SHOWACLS from the Windows Server 2003 Resource Kit Tools is a better alternative:
 CD /D d:\directory2check
 SHOWACLS /U:domain\userid

When did someone last change his password?

With the native NET command:
 NET USER loginname /DOMAIN | FIND /I "Password last set"

How do I reset someone's password?

With the native NET command:
 NET USER loginname newpassword /DOMAIN
With (native) Windows Server 2003 commands:
 DSQUERY USER -samid loginname | DSMOD USER -pwd newpassword
Note: To prevent the new password from being displayed on screen replace it with an asterisk (*); you will then be prompted (twice) to type the new password "blindly".

Is someone's account locked?

With the native NET command:
 NET USER loginname /DOMAIN | FIND /I "Account active"
The account is either locked ("Locked") or active ("Yes").

How to unlock a locked account

With the native NET command:
 NET USER loginname /DOMAIN /ACTIVE:YES
or, if the password needs to be reset as well:
 NET USER loginname newpassword /DOMAIN /ACTIVE:YES

Make sure a local user's password never expires

With WMIC (Windows XP Professional or later):
 WMIC.EXE /Node:remotecomputer Path Win32_UserAccount Where Name="user" Set PasswordExpires="FALSE"

Make sure a local user's password will expire

With WMIC (Windows XP Professional or later):
 WMIC.EXE /Node:remotecomputer Path Win32_UserAccount Where Name="user" Set PasswordExpires="TRUE"


List all domains and workgroups in the network

With the native NET command:
 NET VIEW /DOMAIN

List all computers in the network

With the native NET command:
 NET VIEW
or, to list the names only:
 FOR /F "skip=3 delims=\  " %%A IN ('NET VIEW') DO ECHO.%%A
delims is a backslash, followed by a tab and a space.


List all domain controllers

With native Windows 2000 commands:
 NETDOM QUERY /D:MyDomain DC
NETDOM is part of the support tools found in the \SUPPORT directory of the Windows 2000 installation CDROM.
With (native) Windows Server 2003 commands (Active Directory only):
 DSQUERY Server
or, if you prefer host names only (tip by Jim Christian Flatin):
 DSQUERY Server -o rdn


Find the primary domain controller

With native Windows 2000 commands:
 NETDOM QUERY /D:MyDomain PDC
or, to find the FSMO with (native) Windows Server 2003 commands (Active Directory only):
 NETDOM QUERY /D:mydomain.com FSMO
NETDOM is part of the support tools found in the \SUPPORT directory of the Windows 2000 installation CDROM.

List all member servers

With native Windows 2000 commands:
 NETDOM QUERY /D:MyDomain SERVER
NETDOM is part of the support tools found in the \SUPPORT directory of the Windows 2000 installation CDROM.

List all workstations

With native Windows 2000 commands:
 NETDOM QUERY /D:MyDomain WORKSTATION
NETDOM is part of the support tools found in the \SUPPORT directory of the Windows 2000 installation CDROM.

Delete a computer account

With native Windows 2000 commands:
 NETDOM /DOMAIN:MyDomain MEMBER \\computer2Bdeleted /DELETE
NETDOM is part of the support tools found in the \SUPPORT directory of the Windows 2000 installation CDROM.


"I need an up-to-date list of disk space usage for all servers, on my desk in 5 minutes"

Sounds familiar?
With (native) Windows XP Professional or Windows Server 2003 commands:
 FOR /F %%A IN (servers.txt) DO (
  WMIC /Node:%%A LogicalDisk Where DriveType="3" Get DeviceID,FileSystem,FreeSpace,Size /Format:csv | MORE /E +2 >> SRVSPACE.CSV
 )
The only prerequisites are:
  1. SRVSPACE.CSV should not exist or be empty,
  2. a list of server names in a file named SERVERS.TXT, one server name on each line,
  3. and WMIC.EXE, which is native in Windows XP Professional and later.
The CSV file format is ServerName,DeviceID,FileSystem,FreeSpace,Size (one line for each harddisk partition on each server).
If you have a strict server naming convention, SERVERS.TXT itself can be generated with the NET command:
 FOR /F "delims=\  " %%A IN ('NET VIEW ^| FINDSTR /R /B /C:"\\\\SRV\-"') DO (>>SERVERS.TXT ECHO.%%A)
Notes: (1) assuming server names start with "SRV-"; modify to match your own naming convention.
(2) delims is a backslash, followed by a tab and a space.

List all drivers on any PC

With (native) Windows XP Professional or Windows Server 2003 commands:
 DRIVERQUERY /V /FO CSV > %ComputerName%.csv
Or, for remote computers:
 DRIVERQUERY /S remote_PC /V /FO CSV > remote_PC.csv


List all printers on any PC

With (native) Windows XP+ commands:
 WMIC /Node:remote_PC Path Win32_Printer Get DeviceID


List all local administrators

With (native) Windows NT 4+ commands:
 NET LOCALGROUP Administrators
Or, to remove header and footer lines:
 FOR /F "delims=[]" %%A IN ('NET LOCALGROUP Administrators ˆ| FIND /N "----"') DO SET HeaderLines=%%A
 FOR /F "tokens=*"  %%A IN ('NET LOCALGROUP Administrators') DO SET FooterLine=%%A
 NET LOCALGROUP Administrators | MORE /E +%HeaderLines% | FIND /V "%FooterLine%"

Locate rogue DHCP servers

Never had an "illegal" router wreaking havoc on your network yet...?
With a (native) Windows Server 2003 command:
 DHCPLOC -p local_IP_address [ valid_DHCP_server1 [ valid_DHCP_server2 [ .. ] ] ]
DHCPLOC.EXE is native in Windows Server 2003, and will run in Windows XP if copied/installed.
I didn't test this in Windows Server 2003 yet, but in Windows XP you need to press "d" to start the discovery, or "q" to quit.

Disable Windows Firewall for domain only

Disable the firewall only when the computer (e.g. a laptop) is connected to the domain:
 NETSH Firewall Set OpMode Mode = DISABLE Profile = DOMAIN

Completely disable Windows Firewall (not recommended)

Disable the firewall comletely (not recommended unless an alternative enterprise firewall is used that requires you to do so):
 SC [ \\Remote_computer ] Stop SharedAccess
 SC [ \\Remote_computer ] Config SharedAccess start= disabled

Is IP v4 supported on this computer?

Check if IP v4 is supported on the local computer:
 PING 127.0.0.1 | FIND "TTL=" >NUL 2>&1
 IF ERRORLEVEL 1 (ECHO IP v4 NOT supported) ELSE (IP v4 supported)
or:
 WMIC Path Win32_PingStatus WHERE "Address='127.0.0.1'" Get StatusCode /Format:Value | FINDSTR /X "StatusCode=0" >NUL 2>&1
 IF ERRORLEVEL 1 (ECHO IP v4 NOT supported) ELSE (IP v4 supported)
The WMIC command is faster, but requires Windows XP Professional or later.

Is IP v6 supported on this computer?

Check if IP v6 is supported on the local computer:
 PING ::1 | FINDSTR /R /C:"::1:[ˆ$]" >NUL 2>&1
 IF ERRORLEVEL 1 (ECHO IP v6 NOT supported) ELSE (IP v6 supported)
or:
 WMIC Path Win32_PingStatus WHERE "Address='::1'" Get StatusCode >NUL 2>&1
 IF ERRORLEVEL 1 (ECHO IP v6 NOT supported) ELSE (IP v6 supported)
The WMIC command is faster, but requires Windows XP Professional or later.

Which updates were installed on this compter?

Windows 7 and 8:
 DISM /Online /Get-Packages
or:
 WMIC QFE List

DISM will return far more details than WMIC.

Windows 2000 and XP:
 QFECHECK /V
 
 
SOURCE :http://www.robvanderwoude.com