Update Utility Scripts/Display Computer Info.ps1
This commit is contained in:
@@ -9,9 +9,14 @@ Date: 12-09-2023
|
||||
|
||||
#>
|
||||
|
||||
# Variables #
|
||||
|
||||
# Functions #
|
||||
[CmdletBinding(ConfirmImpact = 'Low')]
|
||||
Param(
|
||||
[Parameter(Mandatory = $false,
|
||||
ValueFromPipeLine = $true,
|
||||
ValueFromPipeLineByPropertyName = $true,
|
||||
Position = 0)]
|
||||
[String[]]$ComputerName = $env:COMPUTERNAME
|
||||
)
|
||||
|
||||
# Start Script #
|
||||
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force
|
||||
@@ -29,4 +34,30 @@ $test2.Tostring(".00") + "GB"
|
||||
Get-CimInstance -ClassName Win32_Processor | Select-Object -ExpandProperty Name
|
||||
|
||||
Get-CimInstance -ClassName Win32_ComputerSystem | Select-Object -ExpandProperty SystemType
|
||||
|
||||
$Result = @()
|
||||
foreach ($Computer in $ComputerName) {
|
||||
try {
|
||||
Get-WmiObject -ComputerName $Computer -Class Win32_logicaldisk -ErrorAction Stop | Where-Object { $_.DriveType -eq 3 } | ForEach-Object {
|
||||
$Query = "SELECT BlockSize FROM Win32_volume WHERE DriveLetter ='$($_.DeviceID)'"
|
||||
$Splatt = @{
|
||||
ComputerName = $Computer
|
||||
DriveLetter = $_.DeviceID
|
||||
'BlockSize(KB)' = (Get-WmiObject -ComputerName $Computer -Query $Query).Blocksize / 1KB
|
||||
Description = $_.Description
|
||||
FileSystem = $_.FileSystem
|
||||
'Size(GB)' = '{0:N0}' -f ($_.Size / 1GB)
|
||||
'Free(GB)' = '{0:N0}' -f ($_.FreeSpace / 1GB)
|
||||
'Free(%)' = '{0:N0}' -f ($_.FreeSpace / $_.Size * 100)
|
||||
Compressed = $_.Compressed
|
||||
VolumeName = $_.VolumeName
|
||||
}
|
||||
$Result += New-Object -TypeName PSObject -Property $Splatt
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-Verbose "Unable to read disk information from computer $Computer"
|
||||
}
|
||||
}
|
||||
$Result | Select-Object ComputerName, DriveLetter, 'BlockSize(KB)', 'Size(GB)', 'Free(GB)', 'Free(%)', FileSystem, Compressed, VolumeName, Description
|
||||
# End Script #
|
||||
Reference in New Issue
Block a user