I am learning as I go, this is a small part in a large project but its an inconvenience for me
I am working on a script and one of its functions is to output information about the system.
Now ideally this is the command I would like to use to generate a report of connected drives over 60GB. It lists everything I want.
$size = 60GB
Get-Volume | Where-Object {$_.Size -gt $Size} | Sort-Object {$_.DriveLetter}
I am aware of other commands. They all seem to react the same way to being in a function. So that means I just don't understand what that reason is or how to control that.
If somebody could explain to me why this command outputs differently inside of a function. I've tried Googling however I cannot seem to find anything online. I believe its 100% me not knowing what to Google.
Function ProductConfirmation {
$processor = (Get-ComputerInfo).CsProcessors.Name
$product = (Get-WmiObject win32_baseboard).Product
$gpuname = (Get-WmiObject win32_videocontroller).Name
$gpudesc = (Get-WmiObject win32_videocontroller).Description
systeminfo | Select-String 'BIOS Version',
'Network Card(s)',
'OS Name',
'OS Version',
'System Manufacturer',
'System Model',
'System Type',
'Time Zone'
Write-Host "`nCPU: $processor"
Write-Host "`nMotherboard: $product"
Write-Host "`nGPU Name: $gpuname"
Write-Host "GPU Description: $gpudesc"
Start-Sleep -s 5
Write-Host "`n RAM INFORMATION`n"
Get-CimInstance -Class CIM_PhysicalMemory -ErrorAction Stop | Select 'Manufacturer',
'DeviceLocator',
'PartNumber',
'ConfiguredClockSpeed'
''
systeminfo | Select-String 'Total Physical Memory'
Start-Sleep -s 4
Write-Host "`n Generating Hard Drive Report`n`n`n"
Write-Host " Double check all drives that should be with this computer are connected." -ForegroundColor RED
Start-Sleep -s 4
$size = 60GB
Get-Volume | Where-Object {$_.Size -gt $Size} | Sort-Object {$_.DriveLetter}
}
ProductConfirmation
Attached are the outputs of both commands run in a VM.
Top - Run in its function Bottom - Run on its own