JBNX | GAMER GEAR
US VETERAN OWNED COMPANY SUPPLYING THE BEST MERCH FOR FELLOW GAMERS.
Wednesday, February 10, 2016
Tuesday, July 28, 2015
Sysinternals: DU (Disk Usage) - Reusable Batch File
Every time the drive starts filling up, I have to figure out where the culprit is. I wrote this batch script to save on a mountable share drive and run it whenever I have an issue. The script will scan the C: drive and save a report to the location where the batch file is located.
Click here to download the Sysinternals utility
I recommend opening the report in EXCEL to better sort through the data
Click here to download the Sysinternals utility
I recommend opening the report in EXCEL to better sort through the data
:: OPTIONAL LINE to not show commands running
@echo off
:: Change directory to current working directory where batch file is located
@cd %~dp0
:: run disk usage utility in quiet mode against the C: drive and export to file named after computer name
@du -v -q c: > %computername%.txt
:: close the command window
@exit
- JBNX
Friday, February 25, 2011
SQL: Dynamically List Tables in SQL
SQL Server 2005 or 2008:
SELECT * FROM information_schema.tables SQL Server 2000:SELECT * FROM sysobjects WHERE xtype='U'
Wednesday, February 23, 2011
Friday, February 18, 2011
SQL: Ping Test Stored Procedure
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[sp_Ping]
@hostname varchar(255)
AS
BEGIN
SET NOCOUNT ON;
DECLARE @cmd sysname
SET @cmd = 'ping -n 1 ' + @hostname
CREATE TABLE #tmp( Result VARCHAR(255) )
INSERT INTO #tmp EXEC xp_cmdshell @cmd
IF EXISTS(
SELECT * FROM #tmp
WHERE Result LIKE '%Reply%' )
PRINT 'REPLY'
ELSE
PRINT 'TIMEOUT'
DROP TABLE #tmp
END
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[sp_Ping]
@hostname varchar(255)
AS
BEGIN
SET NOCOUNT ON;
DECLARE @cmd sysname
SET @cmd = 'ping -n 1 ' + @hostname
CREATE TABLE #tmp( Result VARCHAR(255) )
INSERT INTO #tmp EXEC xp_cmdshell @cmd
IF EXISTS(
SELECT * FROM #tmp
WHERE Result LIKE '%Reply%' )
PRINT 'REPLY'
ELSE
PRINT 'TIMEOUT'
DROP TABLE #tmp
END
Logparser: Converting EVT to EVTX
Getting "Task Aborted" errors?
wevtutil export-log application.evt application.evtx /lf
Wednesday, February 16, 2011
SQL: Group By Date, Show EventCount and ErrorCount
USE EventLogs
SELECT
CAST( FLOOR( CAST( a.TimeWritten AS FLOAT ) ) AS SMALLDATETIME ) AS 'Date',
COUNT( a.EventID ) AS 'EventCount',
(
SELECT COUNT( * )
FROM log_CCRVCU01 b
WHERE
CAST( FLOOR( CAST( a.TimeWritten AS FLOAT ) ) AS SMALLDATETIME )
= CAST( FLOOR( CAST( b.TimeWritten AS FLOAT ) ) AS SMALLDATETIME )
AND
b.EventType = 1
) AS 'ErrorCount'
FROM log_CCRVCU01 a
GROUP BY
CAST( FLOOR( CAST( a.TimeWritten AS FLOAT ) ) AS SMALLDATETIME )
SELECT
CAST( FLOOR( CAST( a.TimeWritten AS FLOAT ) ) AS SMALLDATETIME ) AS 'Date',
COUNT( a.EventID ) AS 'EventCount',
(
SELECT COUNT( * )
FROM log_CCRVCU01 b
WHERE
CAST( FLOOR( CAST( a.TimeWritten AS FLOAT ) ) AS SMALLDATETIME )
= CAST( FLOOR( CAST( b.TimeWritten AS FLOAT ) ) AS SMALLDATETIME )
AND
b.EventType = 1
) AS 'ErrorCount'
FROM log_CCRVCU01 a
GROUP BY
CAST( FLOOR( CAST( a.TimeWritten AS FLOAT ) ) AS SMALLDATETIME )
Subscribe to:
Posts (Atom)