• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1744
  • Last Modified:

How to run a exchange powershell script in silent moder?

Hi Experts,
I use a exchange powershell script which I call through an external Java program to create a mail box. The script works fine. However every time the script is called it the powershell window pops up until the script runs and closes automatically, This could be a problem when I would have call the exchange powershell script for 100 users at a given time to create mailboxes, as there will be 100 powershell windows opening and closing. I will attach the vb script below, appreciate if you can please provide a solution to it
' This Script is used for creating Mailboxes for Active Directory Users.
' This script triggers a Power Shell Script which creates the mailbox for the Active
' Directory User.
'
Set args = WScript.Arguments
' Argument 0 contains the Log On Name
Wscript.echo args.Item(0)
' Argument 1 contains the Mail Store Database Name
Wscript.echo args.Item(1)
' Argument 2 contains the Primary SMTP Address
Wscript.echo args.Item(2)
' Argument 3 contains the Report Log Path
Wscript.echo args.Item(3)
on error resume Next
dim shell
set shell=createobject("wscript.shell")
'Firing the Power Shell command from VB Script
shell.run "PowerShell.exe -PSConsoleFile ""d:\Exchange Server\Bin\exshell.psc1"" -noexit ""&{""Enable-Mailbox '"&args.Item(0)&"' -Database '"&args.Item(1)&"' –PrimarySmtpAddress  '"&args.Item(2)&"'"";""exit 0""} 2>&1 >> "&args.Item(3)&"",,20
If Err.Number <> 0 Then 
      Wscript.Echo("Error Occurred " & Err.description)
             Wscript.quit(2)
End If 
Wscript.quit(3)

Open in new window

0
itsme_asif
Asked:
itsme_asif
1 Solution
 
LeeDerbyshireCommented:
You might try changing the value of the second parameter in that shell.run line:
http://msdn.microsoft.com/en-us/library/d5fk67ky(VS.85).aspx
maybe a 0 will do it?
0
 
martingagnonCommented:
Try to use the 0 parameter on the shell.run line.

Example:
shell.run("notepad.exe", 0, True);

The 0 parameter should run the command in a hidden window.  The true parameter will wait for the command to complete.
0
 
itsme_asifAuthor Commented:
Thanks very much. adding 0, did the trick.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now