Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Lists all files on a drive or drives
- # Version: 1.0A
- # Date Modified: 30/07/17
- # Author: hl2guide
- # Sets a list of drive letters (seperated by *)
- $drivesstring = 'g*h*m*v*w*x*y'
- $drives = @($drivesstring.split('*'))
- # Loops through drive list
- foreach ($drive in $drives)
- {
- # Sets Drive Letter
- $driveLetter = $drive
- Write-Host
- Write-Host 'Creating File List for the drive:' $drive
- # Gets the label of the disk
- $VolumeName = [System.IO.DriveInfo]::getdrives() | Where-Object {$_.Name -eq "$driveLetter"+':\'} | Select-Object -Property VolumeLabel
- $VolumeName = $VolumeName.VolumeLabel.ToString()
- # Gets the list of files on the disk
- $data = Get-ChildItem -Path $driveLetter':\' -Recurse -File -Name | sort length –Descending
- # Outputs the list to a text file
- $outputPath = $PSScriptRoot+"\all_files_on_$driveLetter-($VolumeName).txt"
- Set-Content -Path $outputPath -Value $data
- Write-Host
- Write-Host 'Target Folder was:' $PSScriptRoot
- Write-Host 'Created File List at:' $outputPath
- }
Advertisement
Add Comment
Please, Sign In to add comment