Need to Convert Powershell Script int VBS

Greeting Experts,
Over the past several days, I have been working on a PowerShell script designed to pull different types of information about a computer (i.e. system info, process, services, and ping/tracert  so it can be looked at by network admin in different location (script below). My problem is with the “Set-Executionpolicy” which by the way is set to “Restricted” by default.  Normally this could be corrected by changing the policy to Unrestricted via GPO on the network but I not able to do that.


So I thought about converting the existing PowerShell script I have over to legacy VB script language. My problem is that I am not that well versed in visual basic and was hoping somebody could covert it for me.  This is just a simple script pulling down information and placing into one file and then emailing automatically emailing back to the remote admin.

Can somebody take a stab at and see if this can be converted over.


# Getting Device Services:
Get-Process | Out-File "C:\PSscripts\Diag-Result.txt"
# Getting Device Proccesses:
Get-Service | ? {$_.status -eq "running"} | Out-File "C:\PSscripts\Diag-Result.txt" -Append
# Getting Device System Info:
Get-WmiObject -Class Win32_operatingsystem | Select -Property * | Out-File "C:\PSscripts\Diag-Result.txt" -Append
# Ping 4 Core Internal Destinations:
"10.20.0.92", "10.9.40.1", "10.21.64.1", "10.40.4.10" | % {  pathping -n -p 10 $_} | Out-File "C:\PSscripts\Diag-Result.txt" -Append
# Ping 4 External Destinations:
"www.yahoo.com", "www.bing.com", "google.com", "www.linkedin.com" | % {  pathping -n -p 10 $_}  | Out-File "C:\PSscripts\Diag-Result.txt" -Append
#------------------------------------------------------------------
# Sending Email with Attachment 
$mail = New-Object System.Net.Mail.MailMessage
$mail.From = "user@Domain.com“;
# Change To.Add to your own email address so Diag-Result File can be sent back to you  "YourEmailAdd@Hubbell.com"
$mail.To.Add("user@Domain.com");
$mail.Subject = "Diagnostic Report";
$mail.Body = "Diagnostic Report. Please Review";
$emailattachment = "C:\PSscripts\Diag-Result.txt"
$attachment = New-Object System.Net.Mail.Attachment($emailattachment, 'text/plain')  
$mail.Attachments.Add($attachment)  
$smtp = New-Object System.Net.Mail.SmtpClient("relay.Domain.com");
#$smtp.Credentials = New-Object System.Net.NetworkCredential("UserName","passwrod");
$smtp.Send($mail);
#--------------------------------------------

# End of Script 

Open in new window

MikeSecurityAsked:
Who is Participating?
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.

Phil BossmanSenior Client Systems AdminstratorCommented:
If you wrote the script and can verify the security and integrity of the script, then call powershell.exe with the ByPass.    Execution Policy is not meant to be a security mechanism, but a barrier for unintended use.  

The script is text, readable, and auditable, so any admin you share it with can verify and edit to suit his/her environment.

From Microsoft TechNet:
It may seem odd to permit users to override an administrator-established value for the execution policy, but remember that the execution policy is intended to help stop unintended script execution. It is not intended to stop skilled users from executing scripts at all, merely to ensure that they do not do so without knowing what they are doing.
1

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 for the help...!!
0
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
Powershell

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.