SSR-IS
asked on
Change Powershell Script Output Format
Hi there,
I´ve written a Powershell script that gives me back the installed OS, installed service pack, processor architecture and shows of SNMP installed or not. This script works for me so far, but the output in a textfile is not like I would need it to be (I want to import it to Excel).
Can someone point out what needs to be changed to get a good table-based output?
Code is attatched, the script is started as ./getos.ps1 >> "D:\testscript.txt"
Regards
Steffen
I´ve written a Powershell script that gives me back the installed OS, installed service pack, processor architecture and shows of SNMP installed or not. This script works for me so far, but the output in a textfile is not like I would need it to be (I want to import it to Excel).
Can someone point out what needs to be changed to get a good table-based output?
Code is attatched, the script is started as ./getos.ps1 >> "D:\testscript.txt"
Regards
Steffen
$arrComputers = get-Content -path "c:\servers.txt"
foreach ($strComputer in $arrComputers)
{
$collItems = Get-WmiObject -class "Win32_OperatingSystem" -namespace "root\CIMV2" -computername $strComputer
foreach ($objItem in $collItems)
{
"Computer Name: ;" + $strComputer
"Operating System: ;" + $objItem.Caption
"Servicepack: ;" + $objItem.ServicePackMajorVersion
" "
}
$collSNMP = Get-WmiObject -class "Win32_service" -namespace "root\CIMV2" -computername $strComputer | Where-Object {$_.Name -eq "SNMP"}
foreach ($objItem in $collSNMP)
{
"SNMP: ;" + $objItem.Name
" "
}
$collProcArch = Get-WmiObject -class "Win32_processor" -namespace "root\CIMV2" -computername $strComputer | Select-Object Caption
foreach ($objItem in $collProcArch)
{
"Architecture: ;" + $objItem.Caption
}
" "
"--------------------------------------------------------------"
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER