Windows – What is in your System Drive – C:\WINDOWS\SoftwareDistribution\Download Folder?

Background

Trying to see what is taking up space on an OS Drive.

Tools to Use

OS Drive View

SpaceSniffer

BTW, SpaceSniffer is available here.

Here is what SpaceSniffer came up with.

spacesniffer-brushedup

 

Which Applications is using our big folders?

One of the folders that is big is C:\WINDOWS\SoftwareDistribution\Download

As the C:\WINDOWS\SoftwareDistribution\Download folder is in use by many applications, let us see which Application is using the most storage.

 

Explorer View

In Explorer, select the Title Bar, and add the following columns:

  1. Company
  2. Description

 

Choose Details

choosedetails

 

Files

Here are the files ordered by Size in Descending Order:

mswindowsexplorer

Explanation:

  1. 1258935150ae2e1692ddee617d6fd408259eff42
    • 120 MB
    • Microsoft Antimalware Signature Package Redirector
  2. From Aug-11th to Aug-18
    • 19 MB
    • AntiMalware Definition Update

 

AntiMalware Definition Update

multiplefiles19mbeach

 

PowerShell

Script


<# .PARAMETER folder The name of the folder .PARAMETER maxFiles The maximum # of files #>
param
(
	 [Parameter(Mandatory=$true)]
	 [string]$folder="C:\WINDOWS\SoftwareDistribution\Download"
	
	,[Parameter(Mandatory=$false)]
	 [int]$maxFiles=15
	 
)
	
Set-StrictMode -Version 2

##
# start of script
##
#[System.Type]$Global:ConvertSize = $null;
#[String]$Global:ConvertSize = $null;

Function Convert-Size {
    <# .SYSNOPSIS Converts a size in bytes to its upper most value. .DESCRIPTION Converts a size in bytes to its upper most value. .PARAMETER Size The size in bytes to convert .NOTES Author: Boe Prox Date Created: 22AUG2012 .EXAMPLE Convert-Size -Size 568956 555 KB Description ----------- Converts the byte value 568956 to upper most value of 555 KB .EXAMPLE Get-ChildItem | ? {! $_.PSIsContainer} | Select -First 5 | Select Name, @{L='Size';E={$_ | Convert-Size}} Name Size ---- ---- Data1.cap 14.4 MB Data2.cap 12.5 MB Image.iso 5.72 GB Index.txt 23.9 KB SomeSite.lnk 1.52 KB SomeFile.ini 152 bytes Description ----------- Used with Get-ChildItem and custom formatting with Select-Object to list the uppermost size. #>
    [cmdletbinding()]
    Param (
        [parameter(ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True)]
        [Alias("Length")]
        [int64]$Size
    )
    Begin 
	{
		if ($Global:ConvertSizeDefined -eq $false) 
		{
		
            Write-Verbose ("Creating signature from Win32API")
			
            $Signature =  @"
                 [DllImport("Shlwapi.dll", CharSet = CharSet.Auto)]
                 public static extern long StrFormatByteSize( long fileSize, System.Text.StringBuilder buffer, int bufferSize );
"@
			 
            $Global:ConvertSize = Add-Type -Name SizeConverter -MemberDefinition $Signature -PassThru
			
        }
		
        Write-Verbose ("Building buffer for string")
		
        $stringBuilder = New-Object Text.StringBuilder 1024
		
    }
	
    Process 
	{
        Write-Verbose ("Converting {0} to upper most size" -f $Size)
        $ConvertSize::StrFormatByteSize( $Size, $stringBuilder, $stringBuilder.Capacity ) | Out-Null
        $stringBuilder.ToString()
    }
	
}

if(-not($folder)) 
{ 
	Throw “You must supply a value for -folder” 
}

[bool]$Global:ConvertSizeDefined = $false;
$MaxFilesDefaut = 15

if(-not($maxFiles)) 
{
	$maxFiles = $MaxFilesDefaut
}


#Get Files in Folders Ordered By Size
$files = Get-ChildItem $folder | Sort-Object length  -Descending

#Get # of Folders & Files
$iFileCount = $files.Count

$iFileID = 0;
$iFilesProcessed=0

#Iterate Folders and Files
for ($iFileID=0; $iFileID -lt $iFileCount; $iFileID++) `
{

	$objFile = $files[$iFileID]
	$filename = $objFile.Name.Trim()	
	$filenameFull = $objFile.FullName
	$strFileSize= "";

	# Get File Item
	$objFileItem = Get-Item $filenameFull
	
	# Get File Type
	$objFileType = $objFileItem.GetType()
	
	# Make sure is File and not a Folder
	if ($objFileItem -is [system.io.fileinfo])
	{

		# Increment File Processed Counter
		$iFilesProcessed = $iFilesProcessed + 1;
		
		#Get File Size
		$iFileSize = $objFileItem.length
		
		#Covert File Size to Human Readable Fashion
		$strFileSize = Convert-Size($iFileSize)
		
		
		#Get File Info
		$info= [system.Diagnostics.FileVersionInfo]::GetVersionInfo($filenameFull)
		
		# If File Info is good
		if ($info)
		{
			"File ID			 : {0}" -f $iFilesProcessed 
			"File CompanyName 	 : {0}" -f  $info.CompanyName
			"File Name	         : {0,-40}" -f $filename.Trim()
			"File Description 	 : {0}" -f  $info.filedescription
			"File Size     		 : {0}" -f  $strFileSize.Trim()
			Write-Host ""
		}

		# Break if Max Files 
		if ($iFilesProcessed -ge $maxFiles) 
		{ 
			break; 
		}
	
	} # if ($objFileItem is [system.io.fileinfo])
	

	
}	
	 
	 

 

Sample Invocation


powershell ./Get-FilesInfo.ps1  -folder C:\WINDOWS\SoftwareDistribution\Download -maxFiles 15

Output

getfilesinfo

 

 

Source Code Version Control

Git Hub

Files

 

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s