title: Configure Smtp Virtual Server in windows Server using Powershell-(Relay,Connection)
body: <p>Using powershell I have to enable SMTP and </p>
  
  <ul>
  <li>Add relay Ip</li>
  <li>Add connection IPs</li>
  <li>Set Access Control Authentication</li>
  </ul>
  
  <p>I found following code for the above operation</p>
  
  <pre><code>$GetSMTP = Get-CimInstance -Namespace "root\MicrosoftIISv2" -Class "IISSMTPServerSetting" -Filter "Name ='SmtpSvc/1'"
  $RelayIps =  @(10,92,32,83,127,0,0,1)
  $GetSMTP.RelayIpList = $RelayIps
  Set-CimInstance -InputObject $GetSMTP
  
  $GetSMTP
  $GetSMTP = Get-CimInstance -Namespace "root\MicrosoftIISv2" -Class "IIsIPSecuritySetting" -Filter "Name ='SmtpSvc/1'"
  
  $NewConnectionIps = @(
                       "10.92.32.80, 10.92.32.81";
                       "10.92.32.83,127.0.0.1";
                        )
  $GetSMTP.ipgrant += $NewConnectionIps
  Set-CimInstance -InputObject $GetSMTP
  
  $GetSMTP
  </code></pre>
  
  <p>The above powershell code executed successfully and it list as it is added.</p>
  
  <p>But when i connect to smtp server, the following error is throwing</p>
  
  <p><img src="https://i.stack.imgur.com/AnpWM.png" alt="enter image description here"></p>
  
  <p>I have a found a solution to solve the above issue, To delete the folders inside "C:\inetpub\mailroot" and where i am able to start the default Smtp Virtual Server, but again facing an issue while click smtp vitrual server properties</p>
  
  <p><img src="https://i.stack.imgur.com/YPHY6.png" alt="enter image description here"></p>