Closed OgJAkFy8 closed 4 years ago
Added the following function:
<#bookmark Workstation Information #>
function Get-WorkstationInfo
{
param(
[Parameter(Position = 0)]
[ValidateSet('Manufacturer','Model','Name','PrimaryOwnerName','Domain','serialnumber')]
[String]$Info
)
Write-Verbose -Message ('Enter Function: {0}' -f $PSCmdlet.MyInvocation.MyCommand.Name)
if($Info -eq 'serialnumber'){
(Get-WmiObject -Class win32_SystemEnclosure).serialnumber
}
else{
(Get-WmiObject -Class:Win32_ComputerSystem).$Info
}
} # End Workstation Information-Function
Then the following code:
Write-Verbose -Message 'Getting Serial Number'
$ComputerStat['SerialNumber'] = Get-WorkstationInfo -Info serialnumber
Write-Verbose -Message 'Getting Serial Number'
$ComputerStat['Manufacturer'] = Get-WorkstationInfo -Info Manufacturer
Write-Verbose -Message 'Getting Serial Number'
$ComputerStat['Model'] = Get-WorkstationInfo -Info Model
Completed.
$computerSystem = (Get-WmiObject -Class:Win32_ComputerSystem) Write-Host $computerSystem.Manufacturer Write-Host $computerSystem.Model