Member 14055821 Ответов: 1

Возможно ли, чтобы машина автоматически сообщала данные WMI в электронную таблицу/базу данных при запуске?


I am working on an asset management database and I am currently going out and trying to poll all of the devices on my network with powershell for specific pieces of data in WMI(Name, Serial, Processor, RAM, etc.) and putting it in an excel spreadsheet so I have a general idea of what we have in the environment. So far this is working relatively well but due to the number of machines and location of them I am unable to poll them all successfully. This is partly due to the fact that some devices are turned off when the polling happens or aren't on the network at all. After thinking about it I was curious if it was possible to do this in reverse. Rather than going out and getting the information if there was a way to turn my script into something that runs when a user logs in and uploads the data to an always on file share.

Что я уже пробовал:

#Get the computer list
$servers = Get-Content C:\Data Collection\Computer list.txt
#Run the commands for each computer in the list
$infoColl = @()
Foreach ($s in $servers)
{
    $ComputerSystem = Get-WmiObject Win32_ComputerSystem -ComputerName $s #Get ComputerSystem Information
    $BIOS = Get-WmiObject Win32_BIOS -ComputerName $s #Get BIOS Information
    $CPUInfo = Get-WmiObject Win32_Processor -ComputerName $s #Get CPU Information
	$OSInfo = Get-WmiObject Win32_OperatingSystem -ComputerName $s #Get OS Information
	#Get Memory Information. The data will be shown in a table as MB, rounded to the nearest second decimal.
	$PhysicalMemory = Get-WmiObject CIM_PhysicalMemory -ComputerName $s | Measure-Object -Property capacity -Sum | % { [Math]::Round(($_.sum / 1GB), 2) }
	Foreach ($CPU in $CPUInfo)
    	{
		$infoObject = New-Object PSObject
		#The following add data to the infoObjects.	
		Add-Member -inputObject $infoObject -memberType NoteProperty -name "Computer Name" -value $CPU.SystemName
        Add-Member -inputObject $infoObject -memberType NoteProperty -name "Install Date" -value $OSInfo.InstallDate
		Add-Member -inputObject $infoObject -memberType NoteProperty -name "Processor" -value $CPU.Name
		Add-Member -inputObject $infoObject -memberType NoteProperty -name "Serial" -value $BIOS.SerialNumber
		Add-Member -inputObject $infoObject -memberType NoteProperty -name "Model" -value $ComputerSystem.model
        Add-Member -inputObject $infoObject -memberType NoteProperty -name "User Name" -value $ComputerSystem.UserName
		Add-Member -inputObject $infoObject -memberType NoteProperty -name "OS Name" -value $OSInfo.Caption
		Add-Member -inputObject $infoObject -memberType NoteProperty -name "OS Version" -value $OSInfo.Version
		Add-Member -inputObject $infoObject -memberType NoteProperty -name "Installed Memory" -value $PhysicalMemory
		$infoObject #Output to the screen for a visual feedback.
		$infoColl += $infoObject
	}
}
$infoColl | Export-Csv -path C:\Data Collection\Computer_Inventory_$((Get-Date).ToString('MM-dd-yyyy')).csv -NoTypeInformation #Export the results in csv file.

1 Ответов

Рейтинг:
0

RickZeeland

Я не специалист по сетям, но это может быть возможно в домене, использующем "события входа в учетную запись аудита":
Аудит событий входа в учетную запись: редактор конфигурации безопасности; Службы безопасности | Microsoft Docs[^]