$strComputer = Read-Host "Enter Machine name"
$strDate = Get-Date -Format M.d.yyyy
$csvFilePath = 'C:\'
$strLog = New-Item -ItemType file $csvFilePath\$strComputer-$strDate.log
-Force
$software = gwmi -Namespace root\CIMV2 -Class Win32_Product -ComputerName
$strComputer | Select Name, Version
Add-Content $strLog $software
What it places in the log file is the following :
@{Name=VMware Tools; Version=3.1.1.3705}
@{Name=MSXML 6 Service Pack 2 (KB954459); Version=6.20.1099.0}
@{Name=Microsoft .NET Framework 3.0 Service Pack 1; Version=3.1.21022}
@{Name=Microsoft .NET Framework 2.0 Service Pack 1; Version=2.1.21022}
@{Name=Quarantine Server; Version=3.5.0}
@{Name=Reporting Server (Symantec Corporation); Version=1.0.197.0}
@{Name=CorpServerTuner; Version=6.0}
@{Name=Windows Rights Management Client Backwards Compatibility SP2;
Version=5.2.70}
@{Name=Microsoft SQL Server Desktop Engine; Version=8.00.2039}
@{Name=Windows Presentation Foundation; Version=3.0.6920.0}
How do I get rid of the @{} stuff. I would just like to show the name of
the software and the version number.
foreach ( $i in $software ) { add-content $strLog ($i.name+"`t"+
$i.version) }
Powershell is sometimes little bit too intelligent ;)
Martin
Get-WmiObject -Class Win32_Product | Select Name, version | Export-Csv
sw.txt -NoTypeInformation
Import-Csv sw.txt
Change the file names to yours
--
Richard Siddaway
All scripts are supplied "as is" and with no warranty
PowerShell MVP
Blog: http://richardsiddaway.spaces.live.com/
PowerShell User Group: http://www.get-psuguk.org.uk
Martin
"RG" <R...@discussions.microsoft.com> wrote in message
news:34B355C8-F521-4B39...@microsoft.com...
this will work
$data = Get-WmiObject -Class Win32_Product | Select Name, version | out-string
add-content sw.txt $data
but some of the long names will be truncated
if you want the full name could try something like this
Get-WmiObject -Class Win32_Product | Select Name, version | foreach {
$data = "{0},{1}" -f $($_.Name), $($_.version)
Add-Content sw.txt $data