Page 1 of 6

computer asset inventory

Posted: Wed Feb 27, 2008 4:46 am
by jcconsulting
We have around 30 servers in our environment. I want to
run a script that will show a list of selected host names, version of ISCSI
software running, and version of NIC driver installed in a nice layout or
spreadsheet. Have any resources?

Thanks ..

computer asset inventory

Posted: Wed Feb 27, 2008 5:48 am
by jvierra

computer asset inventory

Posted: Wed Mar 05, 2008 11:56 pm
by donj
I'd write a filtering function.Function Get-Info { PROCESS { # your code goes here. Use $_ for the computer name. }}Get-Content ListOfNames.txt | Get-InfoThe code in the PROCESS scriptblock will run once for each line of text in the file. Within the PROCESS scriptblock, just paste your normal code, but use $_ as a placeholder for the computer name.

computer asset inventory

Posted: Fri Mar 07, 2008 3:43 am
by dee
nevermind. i just removed the -credentials from the remaining section and just left it for the computer info. sections. works good. do you know which object gives the current softwares installed, the ip address?

thanks,
dee

computer asset inventory

Posted: Fri Mar 07, 2008 3:53 am
by dee
The following is what I currently have:

Code: Select all

Function Get-Info { 
	PROCESS { 
	# 
	"----------------------------------------------------------" 
	" Computer Information" 
	"----------------------------------------------------------" 
	get-wmiobject -query "SELECT * FROM Win32_ComputerSystem" -ComputerName $_ -Credential   someuser | 
	select-object Name , Domain , Description , Manufacturer , Model , NumberOfProcessors , ` 
	TotalPhysicalMemory,SystemType,PrimaryOwnerName,UserName 
	
	"----------------------------------------------------------" 
	" BIOS Information" 
	"----------------------------------------------------------" 
	get-wmiobject -query "SELECT * FROM Win32_BIOS" -ComputerName $_ -Credential someuser | 
	select-object Name , Version , SMBIOSBIOSVersion 
	
	"----------------------------------------------------------" 
	" CPU Information" 
	"----------------------------------------------------------" 
	get-wmiobject -query "SELECT * FROM Win32_Processor" -ComputerName $_ -Credential someuser | 
	select-object Manufacturer , Name , CurrentClockSpeed , L2CacheSize 
	
	"----------------------------------------------------------" 
	" Operating System Information" 
	"----------------------------------------------------------" 
	get-wmiobject -query "SELECT * FROM Win32_OperatingSystem" -ComputerName $_ -Credential someuser | 
	select-object Caption , BuildNumber , Version , SerialNumber , ServicePackMajorVersion , InstallDate 
	
	"----------------------------------------------------------" 
	" Name of Built-In Administrator Account (Even If Renamed)" 
	"----------------------------------------------------------" 
	get-wmiobject -query "SELECT * FROM Win32_UserAccount" -ComputerName $_ -Credential someuser | 
	where-object { $_SID -match '-500$' } | 
	select-object Name 
	
	"----------------------------------------------------------" 
	" Installed Hotfixes" 
	"----------------------------------------------------------" 
	get-wmiobject -query "SELECT * FROM Win32_QuickFixEngineering" -ComputerName $_ -Credential someuser | 
	select-object HotFixID 
	} 
	} 
	Get-Content c : serverlist.txt | Get-Info


Did I put the # sign in the right location? Weird though I get the following error within PowerGUI Script Editor when running the "Start Debugging" play button:

"A parameter cannot be found that matches parameter name $host.SetShouldExit(35)?? i'm thinking it is specific to PowerGUI Script Editor and not the code, since it works fine within Windows PowerShell V2 (CTP). Please advise. Thanks!

Dee

computer asset inventory

Posted: Thu Mar 13, 2008 11:25 am
by dee
anyway of reducing the number of credential prompts?

computer asset inventory

Posted: Fri Mar 14, 2008 12:12 am
by donj
Potentially. If every computer is using the same credentials:

$cred = Get-Credential (username)

Goes at the top of your script. From there, use -credential $cred instead of specifying a username. That way you're only prompted once.

computer asset inventory

Posted: Fri Mar 14, 2008 12:16 am
by dee
awesome. I will try that out. also, what object obtains network info like IP address and software's installed? i could not find it. Thanks!

Dee

computer asset inventory

Posted: Fri Mar 14, 2008 12:31 am
by donj
You can use WMI's registry provider to read registry keys. I'm sorry, I don't have an iSCSI system personally, so I can't look and tell you where that might be in the registry, if it's in there at all.

computer asset inventory

Posted: Fri Mar 14, 2008 12:53 am
by dee
the prompt kept on coming.. per your advice i did the following:

Code: Select all

Function Get-Info {
	PROCESS {
	# 
	$cred = Get-Credential (elvez)
	"----------------------------------------------------------"
	" Computer Information"
	"----------------------------------------------------------"
	get-wmiobject -query "SELECT * FROM Win32_ComputerSystem" -ComputerName $_ -Credential $cred |
	select-object Name,Domain,Description,Manufacturer,Model,NumberOfProcessors,`
	TotalPhysicalMemory,SystemType,PrimaryOwnerName,UserName
	
	"----------------------------------------------------------"
	" BIOS Information"
	"----------------------------------------------------------"
	get-wmiobject -query "SELECT * FROM Win32_BIOS" -ComputerName $_ -Credential $cred |
	select-object Name,Version,SMBIOSBIOSVersion
	
	"----------------------------------------------------------"
	" CPU Information"
	"----------------------------------------------------------"
	get-wmiobject -query "SELECT * FROM Win32_Processor" -ComputerName $_ -Credential $cred |
	select-object Manufacturer,Name,CurrentClockSpeed,L2CacheSize
	
	"----------------------------------------------------------"
	" Operating System Information"
	"----------------------------------------------------------"
	get-wmiobject -query "SELECT * FROM Win32_OperatingSystem" -ComputerName $_ -Credential $cred | 
	select-object Caption,BuildNumber,Version,SerialNumber,ServicePackMajorVersion,InstallDate
	
	"----------------------------------------------------------"
	" Name of Built-In Administrator Account (Even If Renamed)"
	"----------------------------------------------------------"
	get-wmiobject -query "SELECT * FROM Win32_UserAccount" -ComputerName $_ -Credential $cred |
	where-object {$_SID -match '-500$'} | 
	select-object Name
	
	"----------------------------------------------------------"
	" Installed Hotfixes"
	"----------------------------------------------------------"
	get-wmiobject -query "SELECT * FROM Win32_QuickFixEngineering" -ComputerName $_ -Credential $cred |
	select-object HotFixID
	}
	}
	Get-Content c:serverlist.txt | Get-Info