Pathping / Day 01

Background

Wanted to talk very little about using pathping to get an idea of the route between one and a destination host.

Syntax

The syntax is generic enough.

Enter pathping and the destination’s hostname or IP Address.

Sample


 pathping Haaretz.com

Output

Tracing Route

pathping.haaretz.01.20190310.0756PM

Computing Statistics

pathping.haaretz.02.20190310.0800PM_x

Interpretation

 

There are two sections to pathping’s output.

The sections are “Tracing Route” and “Computing Statistics“.

 

Tracing Route

Each router that is responsible for forwarding the network packet is listed.

Computing Statistics

Allotted Time

Depending on how many routers are encountered time is allotted for processing.

Each router is pinged one hundred times every 0.25 seconds.

That is, 25 seconds is allotted for each router.

Columns

  1. Hop
    • Increasing number for each router
  2. RTT
    • RTT means Round Trip Time
    • The is how long it took to receive response back from that router
  3. Source to Here / Loss / Sent Percentage ( % )
    • Percentile of packets lost
    • If 100 packets were sent, but only 20 acknowledgement was received
    • This number will be ( 100-20) / 100 or 80%
  4. This Node Link / Loss / Sent Percentage ( % )
    • Packet loss information specific to this router
  5. Address
    • Router’s Address

Summary

  1. If you see 100% packet loss, but entries beyond that point
    • That specific router is likely dropping ICMP traffic

 

SQL Server – Installation – DISM

Background

Trying to install Microsoft SQL Server, but ran into a familiar error.

Blockers

Microsoft SQL Server 2005 Setup

System Configuration Check

Images

IIS Feature Requirement

sqlServer.v2005.SystemConfigurationCheck.20190308.0558PM.PNG

ASP.Net Version Registration Requirement

sqlServer.v2005.SystemConfigurationCheck.ASPNetRegistration.20190308.0603PM.PNG

Prerequisite

Installation

DISM

Outline

  1. Get
    • dism /online /get-features
    • dism /online /get-featureinfo
  2. Enable Feature
    • Dism /online /Enable-Feature

Tasks

get-features
Syntax

dism /online /get-features 

Sample

dism /online /get-features | find /i "IIS-ASPNET" 

Output

Feature Name : IIS-ASPNET
Feature Name : IIS-ASPNET45

get-featureinfo
Syntax

dism /online /get-featureinfo 

Sample

dism /online /get-featureinfo /featurename:NetFx3

Output

Deployment Image Servicing and Management tool
Version: 10.0.14393.0

Image Version: 10.0.14393.2457

Feature Information:

Feature Name : NetFx3
Display Name : .NET Framework 3.5 (includes .NET 2.0 and 3.0)
Description : .NET Framework 3.5 (includes .NET 2.0 and 3.0)
Restart Required : Possible
State : Enabled

Custom Properties:

FWLink : http://go.microsoft.com/fwlink/?LinkId=296822

The operation completed successfully.
get-featureinfo
Syntax

Dism /online /Enable-Feature /FeatureName:(feature-name) 

Sample

Dism /online /Enable-Feature /FeatureName:NetFx3 /All

Output

Deployment Image Servicing and Management tool
Version: 10.0.14393.0

Image Version: 10.0.14393.2457

Enabling feature(s)
[==========================100.0%==========================]
The operation completed successfully.

Actual

Here is what we need to do to enable IIS Web Server and the specific features required by SQL Server Engine and Reporting Services.

Enable IIS-Web Server
Code

DISM /Online /Enable-Feature /FeatureName:IIS-WebServer /all
DISM /Online /Enable-Feature /FeatureName:IIS-WebServerManagementTools /all
DISM /Online /Enable-Feature /FeatureName:IIS-WebServerRole /all

Enable IIS-Features
Code

DISM /Online /Enable-Feature /FeatureName:IIS-StaticContent /all
DISM /Online /Enable-Feature /FeatureName:IIS-DefaultDocument /all
DISM /Online /Enable-Feature /FeatureName:IIS-HttpRedirect /all
DISM /Online /Enable-Feature /FeatureName:IIS-DirectoryBrowsing /all

DISM /Online /Enable-Feature /FeatureName:IIS-ASP /all
DISM /Online /Enable-Feature /FeatureName:IIS-ASPNET /all

DISM /Online /Enable-Feature /FeatureName:IIS-ISAPIExtensions /all
DISM /Online /Enable-Feature /FeatureName:IIS-ISAPIFilter /all

DISM /Online /Enable-Feature /FeatureName:IIS-WindowsAuthentication /all

DISM /Online /Enable-Feature /FeatureName:IIS-Metabase /all

DISM /Online /Enable-Feature /FeatureName:IIS-WMICompatibility /all

Win OS – Error – “An unhandled win32 exception occurred in spoolsv.exe”

Background

Have a few MS Windows 2003 computers running in our LAB.

Error

When I do bother to use them there is an arresting error that I have been receiving.

Error – “An unhandled win32 exception occurred in spoolsv.exe”

Image

spool.20190210.png

Textual


An unhandled win32 exception occurred in spoolsv.exe

Trouble Shooting

Control Panel

Printers and Faxes

Outline

  1. Accessed Control Panel
    • Reviewed Printers and Faxes

Images

controlPanel.printersAndFaxes.20190210.png

Event Viewer

Event Viewer \ System

Outline

  1. Launched Event Viewer
    • Review System Events
      • Event ID :- 7031
        • Event #1
          • Source :- Service Control Manager
          • Event ID :- 7031
          • The Print Spooler service terminated unexpectedly. It has done this 1 time(s). The following corrective action will be taken in 60000 milliseconds: Restart the service.

Images

eventViewer.system.20190210.png

 

Remediation

We have an HP LaserJet computer that we have not used in a while.  It is currently turned off.

Outline

  1. Computer
    • Remove HP LaserJet Software installed on computer
    • MS Windows Registry Cleanup

 

Tasks

Remove HP LaserJet Software installed on computer

Removed any installed HP LaserJet software.

MS Windows Registry Cleanup

Outline

Cleanup MS Windows Registry using regedit :-

  1. Start regedit
  2. Navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Environments\Windows NT x86\Drivers
  3. Export Registry sub-key out to a file for safe keeping
  4. Under this key, there will be the keys Version-2 and Version-3
    • The sub-keys under these contain the printer driver configuration information
    • One or the other of these may be absent – not a problem
  5. Maintain each Sub-key
  6. But, search each sub-key for drivers no longer present on the computer
    • On each found sub-key, remove found sub-key
    • In our case
      • HP Laser Jet 2100
      • HP Laser Jet 2100 PCL6

Images

Image – Before

registry.noor.20190210.0159PM.png

Image – After

registry.noor.20190210.0308PM.png

Crediting

Crediting Mr. Shafique Cheena ( Profile )

Shafique Cheena

Event ID 7031 Print Spooler terminated unexpectedly

Link

credit.shafique.20190210

DOS batch file – Counting Lines

Background

Needing to count lines in a file.

Script

DOS / Command Line

Find Command

syntax

find /v /c "" [filename]

sample

find /v /c "" modules.txt

findstr

findstr – type / findstr/find

syntax
findstr /R "." [filename] | find /c /v ""
sample
findstr /R "." products.txt | find /c /v ""

findstr – type / findstr/find

syntax
type [filename] | findstr /r /n "^"| find /c ":"
sample
type products.txt | findstr /r /n "^"| find /c ":"

Win OS :- Remove Temporary Internet Files

Background

Wanted to remove left behind temporary Internet files.

Folder Stats

C:\Users

WinDirStat

Images

Image – WinDirStat

winDirStat.20181218.0249PM.PNG

Explanation
  1. 16 GB

Windows Explorer

Images

Image – Windows Explorer

folderExplorer.TemporaryInternetFiles.20181218.0228PM.PNG

Explanation
  1. 15.9 GB

Script

Script- Dos/Batch

@echo off

rem *************************************************************************************************

    rem https://community.f-secure.com/t5/Common-topics/Cleaning-temporary-Internet/ta-p/18280

    rem In Windows XP, the folder is located here:

        rem C:\Documents and Settings\\Local Settings\Temporary Internet Files\Content.IE5
        rem Note: If you only have one user account on Windows XP, use Administrator as the username.

    rem In Windows Vista and 7, the folder is located here:

        rem C:\Users\\AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.IE5
        rem C:\Users\\AppData\Local\Microsoft\Windows\Temporary Internet Files\Low\Content.IE5

    rem In Windows 8 and 8.1, the folder is located here:
        rem C:\Users\\AppData\Local\Microsoft\Windows\INetCache

    rem *************************************************************************************************

setlocal enabledelayedexpansion

IF "%OS%"=="" GOTO WIN9X

REM Clear Local Variables
rem set "_folderSuffix="
rem set "_folderLowSuffix="

set _folderSuffix=
set _folderLowSuffix=

if exist "%SystemDrive%\Users\%username%\AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.IE5"  (

	set "_folderSuffix=AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.IE5"
	set "_folderLowSuffix=AppData\Local\Microsoft\Windows\Temporary Internet Files\Low\Content.IE5"

)

if exist "%SystemDrive%\Users\%username%\AppData\Local\Microsoft\Windows\INetCache"  (

	set "_folderSuffix=AppData\Local\Microsoft\Windows\INetCache"

)

set "_users=%SystemDrive%\Users"

FOR /D %%F in ("%_users%\*") do (

     set _folder=%%F

     set "_folderContent=%%F\%_folderSuffix%"    

	 if not "%_folderLowSuffix%"=="" (
		set "_folderLowContent=%%F\%_folderLowSuffix%"

		)

     echo Folder Base is !_folder!

     echo Folder Content Regular is !_folderContent!

     dir "!_folderContent!"\* /s 2>nul | find /v /c "::"

     if exist "!%_folderLowContent%" (

		echo Folder Content Low is !_folderLowContent!

		dir "!_folderLowContent!"\* /s 2>nul | find /v /c "::"

	)		

     echo *******************************************************************

     rem dir
     if "%1"=="dir" dir "!_folderContent!"\* /s /Q 2>nul 

     if exist "%%F\%_folderLowSuffix%" (

		if "%1"=="dir" dir "!_folderLowContent!"\* /s /Q 2>nul      

	 )		

     rem del
     if "%1"=="del" del "!_folderContent!"\* /s /Q 2>nul 

     if exist "%%F\%_folderLowSuffix%" (

		if "%1"=="del" del "!_folderLowContent!"\* /s /Q 2>nul      

	)	

)

:GOTO END

:WIN9X

REM - WIN9X systems are currently not supported.

:END

endlocal

Source Code Control

GitHub

DanielAdeniji/winOSInternetTempfilesCleanup
Link

 

Dos Batch File – Special Characters

Background

If you end up having special characters as in the case of nice passwords and also needing to use delayed expansions in your batch file, you might have to escape those passwords.

Batch File

Deploy


@echo off

if not exist log mkdir log

SETLOCAL DISABLEDELAYEDEXPANSION

set "_errorlevelSaved="

REM Batch files - number of command line arguments ( nimrodm )
rem https://stackoverflow.com/questions/1291941/batch-files-number-of-command-line-arguments

set argC=0

for %%x in (%*) do Set /A argC+=1

echo Argument Count is %argC%

set "_app=sqlcmd.exe"

set _dbHost=%1

IF NOT "%2"=="" set "_dbUsername=%2"

IF NOT "%3"=="" set "_dbPassword=%3"

set "_appOption=-S %_dbHost% -b "

IF NOT "%_dbUsername%"=="" set "_appOption=%_appOption% -U%_dbUsername% "

IF NOT "%_dbPassword%"=="" set _appOption=%_appOption% -P"%_dbPassword%"

set "_filename=modules.txt"

echo appOption is %_appOption%

rem goto skipped

SETLOCAL ENABLEDELAYEDEXPANSION

set _fileCount=0

for /f "tokens=1,2 delims=," %%a in ('type %_filename%') do (

	set /A _fileCount+=1

	set _folder=%%a

	set _file=%%b

	set "_fileFull=!_folder!\!_file!"

	echo Processsing file !_fileCount!  - !_fileFull!

	%_app% %_appOption% -i !_fileFull!	

	set "_errorlevelSaved=%errorlevel%"

	rem echo _errorlevelSaved is %_errorlevelSaved%

	IF NOT _errorlevelSaved NEQ 0 GOTO exception

)

:skipped

goto completed

:exception

echo "Error Level %_errorlevelSaved%"

:completed

SETLOCAL DISABLEDELAYEDEXPANSION

endlocal

Invoke

Outline

  1. Server Name :- 118.90.10.1
  2. User :- dadeniji
  3. Password :- paul.winters

Actual Invocation


deploy 118.90.10.1 john paul.winters

Output

Output – Textual

Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : Login failed for user 'dadeniji'..

Output – Image

sqlcmd.specialCharacters.inbatchfile.(dadeniji)20181209.0700AM

 

Workaround

In our case we have special characters in our password and we are getting failed logins, and so we have to escape each special character.

Outline

In this sample we escaped the period in our password.

  1. The actual password is paul.winters.
  2. The only character that needs to be escaped is the period.
  3. And, so we ended up with paul^.winters.

 

Actual Invocation


deploy 118.90.10.1 john paul^.winters

Output

sqlcmd.specialCharacters.inbatchfile.(john.smith)20181209.0707AM

Dedicated

Dedicating to Rob van der Woude’s.

Rob van der Woude’s Scripting Pages
Escape Characters
Link