computer asset inventory

Ask your Windows 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.
User avatar
jcconsulting
Posts: 1
Joined: Wed Feb 27, 2008 4:59 am

computer asset inventory

Post by jcconsulting » Wed Feb 27, 2008 5:46 am

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 ..

User avatar
jvierra
Posts: 13736
Joined: Tue May 22, 2007 9:57 am
Contact:

computer asset inventory

Post by jvierra » Wed Feb 27, 2008 6:48 am


User avatar
donj
Posts: 416
Joined: Thu Nov 16, 2006 9:02 pm

computer asset inventory

Post by donj » Thu Mar 06, 2008 12:56 am

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
Joined: Wed Mar 05, 2008 6:17 am

computer asset inventory

Post by dee » Fri Mar 07, 2008 4:43 am

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
Joined: Wed Mar 05, 2008 6:17 am

computer asset inventory

Post by dee » Fri Mar 07, 2008 4:53 am

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
Joined: Wed Mar 05, 2008 6:17 am

computer asset inventory

Post by dee » Thu Mar 13, 2008 11:25 am

anyway of reducing the number of credential prompts?

User avatar
donj
Posts: 416
Joined: Thu Nov 16, 2006 9:02 pm

computer asset inventory

Post by donj » Fri Mar 14, 2008 12:12 am

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
Joined: Wed Mar 05, 2008 6:17 am

computer asset inventory

Post by dee » Fri Mar 14, 2008 12:16 am

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
Joined: Thu Nov 16, 2006 9:02 pm

computer asset inventory

Post by donj » Fri Mar 14, 2008 12:31 am

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
Joined: Wed Mar 05, 2008 6:17 am

computer asset inventory

Post by dee » Fri Mar 14, 2008 12:53 am

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

Locked