computer asset inventory

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 15 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
jcconsulting
Posts: 1
Last visit: Wed Feb 27, 2008 4:46 am

computer asset inventory

Post 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 ..
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

computer asset inventory

Post by jvierra »

User avatar
donj
Posts: 416
Last visit: Thu May 29, 2008 5:08 am

computer asset inventory

Post 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.
User avatar
dee
Posts: 35
Last visit: Wed May 21, 2008 8:36 am

computer asset inventory

Post 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
User avatar
dee
Posts: 35
Last visit: Wed May 21, 2008 8:36 am

computer asset inventory

Post 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
User avatar
dee
Posts: 35
Last visit: Wed May 21, 2008 8:36 am

computer asset inventory

Post by dee »

anyway of reducing the number of credential prompts?
User avatar
donj
Posts: 416
Last visit: Thu May 29, 2008 5:08 am

computer asset inventory

Post 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.
User avatar
dee
Posts: 35
Last visit: Wed May 21, 2008 8:36 am

computer asset inventory

Post 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
User avatar
donj
Posts: 416
Last visit: Thu May 29, 2008 5:08 am

computer asset inventory

Post 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.
User avatar
dee
Posts: 35
Last visit: Wed May 21, 2008 8:36 am

computer asset inventory

Post 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
This topic is 15 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked