Home » Posts tagged 'Powershell'

Tag Archives: Powershell

Send-MailMessage : Unable to connect to remote server Line

Send-MailMessage -to “reciever@domin.com” -from “sender@domain.com” -Subject “Subject Info” -Body “Content” -SmtpServer “Server Name”

Was not able to send mail from a Windows 2008 server and the error message displayed is as listed below:

Send-MailMessage : Unable to connect to the remote server
At line:1 char:17
+ Send-MailMessage <<<< -to someone@somedomain.com -from “DhimantR@someDomain.com” -subject ” Troubleshooting” -Body “Some Text or file attachement” -sntpserver “smtpserver”
+ CategoryInfo : InvalidOperation: (System.Net.Mail.SmtpClient:SmtpClient) [Send-MailMessage], SmtpException
+ FullyQualifiedErrorId : SmtpException,Microsoft.PowerShell.Commands.Send MailMessage

Found that the the block was in McAfee, when Powershell was excluded from McAfee. Send mail was success.

Steps to exclude Powershell in McAfee is listed below:

  1. Right click on McAfee icon.
  2. Click on Virus Scan Console.
  3. Double click on Access Protection on VirusScan Console.
  4. On Access Protection tab.
  5. Go to Anti-Virus Standard Protection.
  6. On right hand side, double click on Prevent mass mailing worms from sending mail.
  7. On process to exclude tab, add PowerShell.exe at the end.
  8. Click OK.
  9. Click apply on Access Protection.
  10. Click OK.

Thanks,
WintelAdmin

PART 1: Getting started with PowerShell.

Powershell Tutorial – Part 1

To begin PowerShell you need to start using the console. Forget the command prompt and move on to PowerShell. Powershell is a combination of DOS and Unix shell with an update. It accepts both Windows and Unix commands with many new features. Powershell scripting is to do more in less time.

Powershell can be used in two ways – the Console and the integrated Scripted Environment (ISE). ISE is preferred for scripting and console for command execution.

First thing you need to know is how to start PowerShell, simplest is just by typing powershell. Other way to star powershell is double click .ps1 file.

cmdlets (commandlets) are self contained scripts that required to be called like a command. For example, get-service (which list all services and its status), get-command (it lists all comdlets that can be used). multiple cmdlets can be used to make some tasks very simple thats called command pipelining. One comand can take input from another command. and process it.

The command for getting help is get-help and it accepts varietly of arguments.
get-help

Example:
get-help services
This will search and list all command and help files relating to services.

get-help start-service -online
Using the parameter “online” you can open the browser to view the help on TechNet.

get-help start-service -examples
This will list the example for start-services.

 

Thanks,

WintelAdmin

PowerShell for Administrators – Coming Soon

PowerShell essentials for administrators coming soon on WintelAdmin to help with your daily operations.

Stay Tuned…..

WintelAdmin.com

Powershell Script to start/stop/disable service on multiple remote server

Powershell script to control windows service on multiple remote servers.

Get-content “Filename” | foreach {set-Service -ComputerName $_ -Name “Service Name” -StartupType Disabled -Status Stopped}

Note:
Replace Filename with filename location (Ex C:\hostname.txt).
Add all servers names to filesname (Ex hostname.txt)
Change StartupType as Disabled/Manual/Automatic
Change Status as Stopped/started

-WintelAdmin


Visitors Count

Subscriber Count

    4029
June 2017
M T W T F S S
« May    
 1234
567891011
12131415161718
19202122232425
2627282930