sorry nevermind i figured it out. i need to put the full file location with thanks!
Dee
computer asset inventory
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.
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.
computer asset inventory
sorry for the long trail again. I am familiar with ./something.ps1 > something.txt cmdlet But, trying have the cmdlet run within the code. browsing google...
computer asset inventory
also, the only think i did prior was remove some of the select-objects and re-arranged the code. The following is the code:
Function Get-Info ( $cred ) {
PROCESS {
"----------------------------------------------------------" " Server Name and Domain" "----------------------------------------------------------" Get-WmiObject -Query "SELECT * FROM Win32_ComputerSystem" -ComputerName $_ -Credential $cred | Select-Object Name,Domain "----------------------------------------------------------" " Asset Tag" "----------------------------------------------------------" get-wmiobject -Query "SELECT * FROM Win32_BIOS" -ComputerName $_ -Credential $cred | select-object SerialNumber "----------------------------------------------------------" " Operating System & Service Pack" "----------------------------------------------------------" get-wmiobject -Query "SELECT * FROM Win32_OperatingSystem" -ComputerName $_ -Credential $cred | select-object Caption,BuildNumber,Version,ServicePackMajorVersion
"----------------------------------------------------------" " DISK INFORMATION" "----------------------------------------------------------" Get-WmiObject -Query "SELECT * FROM Win32_LogicalDisk" -ComputerName $_ -Credential $cred | Select-Object VolumeName,Name,Size,FreeSpace,FileSystem "----------------------------------------------------------" " NETWORKING" "----------------------------------------------------------" Get-WmiObject -Query "SELECT * FROM Win32_NetworkAdapterConfiguration" -ComputerName $_ -Credential $cred | Select-Object DNSHostName,DNSDomain,DNSServerSearchOrder,Description,IPAddress,DefaultIPGateway,IPSubnet,MACAddress
"----------------------------------------------------------" " MAJOR SOFTWARE" "----------------------------------------------------------" Get-WmiObject -Query "SELECT * FROM Win32_Product" -ComputerName $_ -Credential $cred | select-object Name "----------------------------------------------------------" " ANTIVIRUS PROTECTION" "----------------------------------------------------------" Get-WmiObject -Query "SELECT * FROM cim_datafile where name='c:program filesesetnod32.exe'" -ComputerName $_ -Credential $cred | Select-Object Name "----------------------------------------------------------" " WINDOWS SERVICES DISABLED" "----------------------------------------------------------" Get-WmiObject -Query "SELECT * FROM Win32_Service" -ComputerName $_ -Credential $cred | Where {$_.StartMode -eq "Disabled" -and $_.Status -eq "OK"} | Select-Object Name,Status,StartMode,DisplayName }}$mycred = Get-Credential ("useradmin")Get-Content c:serverlist.txt | Get-Info $mycred
Function Get-Info ( $cred ) {
PROCESS {
"----------------------------------------------------------" " Server Name and Domain" "----------------------------------------------------------" Get-WmiObject -Query "SELECT * FROM Win32_ComputerSystem" -ComputerName $_ -Credential $cred | Select-Object Name,Domain "----------------------------------------------------------" " Asset Tag" "----------------------------------------------------------" get-wmiobject -Query "SELECT * FROM Win32_BIOS" -ComputerName $_ -Credential $cred | select-object SerialNumber "----------------------------------------------------------" " Operating System & Service Pack" "----------------------------------------------------------" get-wmiobject -Query "SELECT * FROM Win32_OperatingSystem" -ComputerName $_ -Credential $cred | select-object Caption,BuildNumber,Version,ServicePackMajorVersion
"----------------------------------------------------------" " DISK INFORMATION" "----------------------------------------------------------" Get-WmiObject -Query "SELECT * FROM Win32_LogicalDisk" -ComputerName $_ -Credential $cred | Select-Object VolumeName,Name,Size,FreeSpace,FileSystem "----------------------------------------------------------" " NETWORKING" "----------------------------------------------------------" Get-WmiObject -Query "SELECT * FROM Win32_NetworkAdapterConfiguration" -ComputerName $_ -Credential $cred | Select-Object DNSHostName,DNSDomain,DNSServerSearchOrder,Description,IPAddress,DefaultIPGateway,IPSubnet,MACAddress
"----------------------------------------------------------" " MAJOR SOFTWARE" "----------------------------------------------------------" Get-WmiObject -Query "SELECT * FROM Win32_Product" -ComputerName $_ -Credential $cred | select-object Name "----------------------------------------------------------" " ANTIVIRUS PROTECTION" "----------------------------------------------------------" Get-WmiObject -Query "SELECT * FROM cim_datafile where name='c:program filesesetnod32.exe'" -ComputerName $_ -Credential $cred | Select-Object Name "----------------------------------------------------------" " WINDOWS SERVICES DISABLED" "----------------------------------------------------------" Get-WmiObject -Query "SELECT * FROM Win32_Service" -ComputerName $_ -Credential $cred | Where {$_.StartMode -eq "Disabled" -and $_.Status -eq "OK"} | Select-Object Name,Status,StartMode,DisplayName }}$mycred = Get-Credential ("useradmin")Get-Content c:serverlist.txt | Get-Info $mycred
computer asset inventory
Thanks. Any way to have it in the start? it was working at one time.... should I put the PoSH first?
computer asset inventory
I have another question. Any way of formating the "FreeSpace" that is in bytes to GB or MB? I tried the following, but the results is just showing blank or just the bytes.
Code: Select all
Get-WMIObject Win32_LogicalDisk |
Select-Object VolumeName,Name,Size,FreeSpace,FileSystem |
ForEach-Object {[math]::truncate($_.Freepace/1GB)}
computer asset inventory
I tried that but, I don't get the right results:
I tried placing the $_.FreeSpace/1GB in other spots of the above code, but no luck yet... any ideas?
Code: Select all
Get-WmiObject -Query "SELECT * FROM Win32_LogicalDisk" -ComputerName $_ -Credential $cred |
Where-Object {$_.drivetype -eq 3} |
Select-Object VolumeName,Name,Size,FreeSpace,FileSystem |
$_.FreeSpace/1GB
computer asset inventory
Nevermind.. I resolved the issue by doing the following:
Code: Select all
Get-WmiObject -Query "SELECT * FROM Win32_LogicalDisk" -ComputerName $_ -Credential $cred |
Where-Object {$_.drivetype -eq 3} |
Select-Object VolumeName,Name,FileSystem,@{Name="Freespace";Expression={$_.FreeSpace/1gb}},@{Name="Size";Expression={$_.Size/1gb}}
computer asset inventory
You still need to format the output. The result will show the float equivalent in GB and will be formatted according to the output method selected. YOu will get a Scietific Notation like output when converting that will need to be rounded to the precision you want to display.
This is a prettyt long winded explanation of how and why this works. It has to do with plain old arithmatic, the size of things like GBs and MBs, and the way you wish to dispay these things. When I get some time I will look for a bolg I once saw that explains this very nicely. YOu really should get one of Don's books as he and Jeff do a pretty complete explanation of these issues although I don't htink it's under a single heading.
This is a prettyt long winded explanation of how and why this works. It has to do with plain old arithmatic, the size of things like GBs and MBs, and the way you wish to dispay these things. When I get some time I will look for a bolg I once saw that explains this very nicely. YOu really should get one of Don's books as he and Jeff do a pretty complete explanation of these issues although I don't htink it's under a single heading.
computer asset inventory
new question:
How do you truncate the following:
LastModified : 20080428114231.585250-300
I would like to have the format be a date format and also to truncate the last 17 digits. I have the following:
How do you truncate the following:
LastModified : 20080428114231.585250-300
I would like to have the format be a date format and also to truncate the last 17 digits. I have the following:
Code: Select all
Get-WmiObject -Query "SELECT * FROM cim_datafile where name='c:program filesesetupdfileslastupd.ver'" -ComputerName $_ -Credential $cred |
Select-Object Name,ModifyDate | Format-List
computer asset inventory
when i put no path it gave no data...
Code: Select all
Get-WmiObject -Query "SELECT * FROM cim_datafile where name='nod32.exe'" -ComputerName $_ -Credential $cred |
Select-Object Name,Version | Format-List