Ik heb regelmatig gehad dat ik info van de computer nodig had mbt geheugen of schijfruimte etc. ook daarvoor heb ik een functie geschreven
Function GetComputerInfoClient{ [CmdletBinding(DefaultParameterSetName="ComputerName")] Param ( [Parameter(ParameterSetName="ComputerName",Position=0)] [string]$ComputerName ) #end Param if (!$ComputerName) { Write-Host "" Write-Host "* Please provide the Hostname: " -NoNewline $ComputerName = Read-Host } #end if If (Test-Connection $ComputerName -count 1 -quiet) { $sysComp = Get-WmiObject Win32_ComputerSystem -ComputerName $ComputerName -ErrorVariable SysError Start-Sleep -m 250 $sysComp2 = Get-WmiObject Win32_ComputerSystemProduct -ComputerName $ComputerName $sysOS = Get-WmiObject Win32_OperatingSystem -ComputerName $ComputerName $sysBIOS = Get-WmiObject Win32_BIOS -ComputerName $ComputerName $sysCPU = Get-WmiObject Win32_Processor -ComputerName $ComputerName $sysCPUName = (Get-WmiObject Win32_Processor -ComputerName $ComputerName | Where-Object {$_.DeviceID -like 'CPU0'}).Name $HT = $($sysCPU | measure-object -Property NumberOfLogicalProcessors -sum).Sum -gt $($sysCPU | measure-object -Property NumberOfCores -sum).Sum $sysCPU1 = Get-WmiObject Win32_ComputerSystem -ComputerName $ComputerName $CoresPerCPU = $($sysCPU | measure-object -Property NumberOfCores -sum).Sum / $sysCPU1.NumberOfProcessors $sysRAM = Get-WmiObject Win32_PhysicalMemory -ComputerName $ComputerName $sysNAC = Get-WmiObject Win32_NetworkAdapterConfiguration -ComputerName $ComputerName -Filter "IPEnabled='True'" $sysMon = Get-WmiObject Win32_DesktopMonitor -ComputerName $ComputerName $sysVid = Get-WmiObject Win32_VideoController -ComputerName $ComputerName $sysOD = Get-WmiObject Win32_CDROMDrive -ComputerName $ComputerName $sysHD = Get-WmiObject Win32_LogicalDisk -ComputerName $ComputerName $sysProc = Get-WmiObject Win32_Process -ComputerName $ComputerName $UserLogonDT = ($sysProc | ?{$_.Name -eq "explorer.exe"} | Sort CreationDate | Select-Object -First 1).CreationDate $UserLogon = [System.Management.ManagementDateTimeconverter]::ToDateTime($UserLogonDT).ToString() $LastBootUpTime = [System.Management.ManagementDateTimeconverter]::ToDateTime($sysOS.LastBootUpTime).ToString() $tRAM = "{0:N2} GB Usable - " -f $($sysComp.TotalPhysicalMemory / 1GB) $sysRAM | %{$tRAM += "[$($_.Capacity / 1GB)] "} $sysHD | ?{$_.DriveType -eq 3} | %{ $HDInfo = "{0:N1} GB Free / {1:N1} GB Total" -f ($_.FreeSpace / 1GB), ($_.Size / 1GB)} $InstallDate = [System.Management.ManagementDateTimeconverter]::ToDateTime($sysOS.InstallDate).ToString() function Get-RPADComputer{ $Properties = $XML.Options.Search.Property if($ComputerName -match "."){$ComputerName = $ComputerName.Split('.')[0]} $searcher=[adsisearcher]"(&(objectClass=computer)(name=$ComputerName*))" #$searcher.PropertiesToLoad.AddRange($Properties) $searcher.SearchRoot=$searchRoot $searcher.FindAll() } $sysOU = Get-RPADComputer $OU = $sysOU.Path.Substring($sysOU.Path.IndexOf(',')+1) cls Write-Host write-host " General Info" -ForegroundColor Green Write-Host write-host "*" -ForegroundColor Yellow -NoNewline; write-host " Hostname " -ForegroundColor Yellow -NoNewline; write-host $sysComp.name -ForegroundColor Cyan write-host "*" -ForegroundColor Yellow -NoNewline; write-host " User " -ForegroundColor Yellow -NoNewline; write-host $sysComp.UserName -ForegroundColor Cyan write-host "*" -ForegroundColor Yellow -NoNewline; write-host " AD OU " -ForegroundColor Yellow -NoNewline; write-host $OU -ForegroundColor Cyan write-host "*" -ForegroundColor Yellow -NoNewline; write-host " User Logon time " -ForegroundColor Yellow -NoNewline; write-host $UserLogon -ForegroundColor Cyan write-host "*" -ForegroundColor Yellow -NoNewline; write-host " System Startup time " -ForegroundColor Yellow -NoNewline; write-host $LastBootUpTime -ForegroundColor Cyan write-host write-host " Hardware Info" -ForegroundColor Green Write-Host write-host "*" -ForegroundColor Yellow -NoNewline; write-host " Manufacturer " -ForegroundColor Yellow -NoNewline; write-host $sysComp.Manufacturer -ForegroundColor Cyan write-host "*" -ForegroundColor Yellow -NoNewline; write-host " Model nr " -ForegroundColor Yellow -NoNewline; write-host $sysComp.Model -ForegroundColor Cyan write-host "*" -ForegroundColor Yellow -NoNewline; write-host " Serial NR " -ForegroundColor Yellow -NoNewline; write-host $sysBIOS.SerialNumber -ForegroundColor Cyan write-host write-host " System Info" -ForegroundColor Green Write-Host write-host "*" -ForegroundColor Yellow -NoNewline; write-host " CPU " -ForegroundColor Yellow -NoNewline; write-host $sysCPUName -ForegroundColor Cyan write-host "*" -ForegroundColor Yellow -NoNewline; write-host " Number of CPU's " -ForegroundColor Yellow -NoNewline; write-host $sysCPU1.NumberOfProcessors -ForegroundColor Cyan write-host "*" -ForegroundColor Yellow -NoNewline; write-host " Cores per CPU " -ForegroundColor Yellow -NoNewline; write-host $CoresPerCPU -ForegroundColor Cyan write-host "*" -ForegroundColor Yellow -NoNewline; write-host " Hyperthreading " -ForegroundColor Yellow -NoNewline; write-host $HT -ForegroundColor Cyan write-host "*" -ForegroundColor Yellow -NoNewline; write-host " Total Logical Processors " -ForegroundColor Yellow -NoNewline; write-host $sysCPU1.NumberOfLogicalProcessors -ForegroundColor Cyan write-host "*" -ForegroundColor Yellow -NoNewline; write-host " Memory " -ForegroundColor Yellow -NoNewline; write-host $tRAM -ForegroundColor Cyan write-host "*" -ForegroundColor Yellow -NoNewline; write-host " C Drive Disk Space " -ForegroundColor Yellow -NoNewline; write-host $HDinfo -ForegroundColor Cyan write-host "*" -ForegroundColor Yellow -NoNewline; write-host " GPU " -ForegroundColor Yellow -NoNewline; write-host $sysVid.Description -ForegroundColor Cyan write-host write-host " OS Info" -ForegroundColor Green Write-Host write-host "*" -ForegroundColor Yellow -NoNewline; write-host " OS " -ForegroundColor Yellow -NoNewline; write-host $sysOS.Caption -ForegroundColor Cyan write-host "*" -ForegroundColor Yellow -NoNewline; write-host " OS-Build " -ForegroundColor Yellow -NoNewline; write-host $sysOS.version -ForegroundColor Cyan write-host "*" -ForegroundColor Yellow -NoNewline; write-host " OS Architecture " -ForegroundColor Yellow -NoNewline; write-host $sysComp.SystemType -ForegroundColor Cyan write-host "*" -ForegroundColor Yellow -NoNewline; write-host " Installation Date " -ForegroundColor Yellow -NoNewline; write-host $InstallDate -ForegroundColor Cyan write-host } else{ Write-Host " Computer is offline " -ForegroundColor RED } } |