Need Help with Powershell Script

Greeting Experts,

Maybe somebody can help with script I am attempting to create…. In effort to help our network services group I have been asked to create a script that can be ran on a desktop and get the following items ( system information, list of process, list of services,  Network Utilization, trace route from  inside/outside ip address, and ping rates from inside/outside ip address). Then import that information in to .csv file and email to admin reasonable. I don’t know if this is possible but if somebody can kindly create a script that can do this I would appreciate that…….
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
It's feasible, but you'll need to have one CSV per task, as the produced data of each task is incompatible to others.
And I suppose you mean a trace route to inside/outside IP.

Best start, however, is if you tell us where the script should be started (is there a VPN?), and what you expect to see failiing. And how "the admin reasonable [sic]" should be determined (by AD? Won't work without a connection. Static?).

I'm also convinced that you can find something similar here on EE already.
Thomas GrassiSystems AdministratorCommented:
Post each command line  you would like to script and the order you would like them in
Bob LearnedCommented:
1) Process list:

Using the Get-Process Cmdlet

2) Service list

Using the Get-Service Cmdlet

3) Using Powershell and WMI to get system information:

Collecting Information About Computers
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

MikeSecurityAuthor Commented:
Some of the stuff I looking to do is some of the following.... What I am looking to do is to tie this up in to one .csv file and then have it email to the admin using the script....

# Get-Process

Get-Service | Where-Object {$_.status -eq "running"}

#Get system information: 
Get-WmiObject -Class Win32_operatingsystem | Select -Property *

# Tracrt

$array =  @("IPaddress", "IPaddress", "IPaddress", "IPaddress")
foreach($element in $array)
  tracert -d -h 10 $element 

Open in new window

Bob LearnedCommented:
You have different approaches that you can use:

1) Use out-file with the append parameter to write to a single file

2) Write the output for each cmdlet to a variable, and build a string that you can write with export-csv.
MikeSecurityAuthor Commented:
I am still a beginner when comes to powershell.... These are examples of what I am trying to accomplish..
Bob LearnedCommented:
Here are out-file examples:


get-process | out-file -filepath C:\Test1\process.txt

Open in new window

Controlling PowerShell's Results with Out-File

| Out-File -Filepath "D:\Files\dll.txt"  -Append

Open in new window

The pipe character creates a bridge between the output of one cmdlet with the input to another.

PowerShell Basics: Objects, Piping, Filtering and More,2-771.html
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
I would use one CSV for each part but the trace route, which should just result in a text file. Then mail all those files.
push-location $env:temp
Get-Process | Export-Csv Processes.csv
Get-Service | ? {$_.status -eq "running"} | Export-Csv ActiveServices.csv
Get-WmiObject -Class Win32_operatingsystem | Select -Property * | Export-Csv OSInfo.csv
"IPaddress", "IPaddress", "IPaddress", "IPaddress" | % {  tracert -d -h 10 $_} | Out-File TraceRt.log

# Send results
Send-MailMessage -SmtpServer -From $ -To -Subject "Connection test script results $($env:ComputerName)" -Attachments Processes.csv, ActiveServices.csv, OSInfo.csv, TraceRt.Log

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MikeSecurityAuthor Commented:
Thanks guys ... that works great....
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.