I have been struggling all day with this and can't seem to make
it work.
ActiveXPosh and Enable-Mailbox doesn't do anything for me
in my script. ActiveXPosh is working for me on other commands like
the ActiveXPosh.Eval("get-process winword") example in the
sample SAPIEN script.
Also, I can run the Enable-Mailbox command in Powershell and it creates my
mailbox but within the code below it does nothing.
Can someone please help me?
Has anyone got ActiveXPosh and Enable-Mailbox to work for them?
I'd appreciate any help or advice. Thanks!
'My Enable Mailbox script
Option Explicit
Dim ActiveXPosh
Dim strStorageGroup
Dim Command
Const OUTPUT_CONSOLE = 0
Const OUTPUT_WINDOW = 1
Const OUTPUT_BUFFER = 2
Function CreateActiveXPosh()
Dim success
Set ActiveXPosh = CreateObject("SAPIEN.ActiveXPoSH")
success = ActiveXPosh.Init(vbFalse)
If success <> 0 then
WScript.Echo "Init failed"
end if
ActiveXPosh.OutputMode = OUTPUT_CONSOLE
End Function
CreateActiveXPosh
strStorageGroup = """LABMBX01Third Storage GroupMailboxDB2"""
Command = "Enable-Mailbox jdoe@mydomain.com -Database " & strStorageGroup
ActiveXPosh.Execute(Command)
ActiveXPosh and Enable-Mailbox
Forum rules
DO NOT POST SUBSCRIPTION NUMBERS, LICENSE KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
DO NOT POST SUBSCRIPTION NUMBERS, LICENSE KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
- Alexander Riedel
- Posts: 6818
- Joined: Tue May 29, 2007 4:43 pm
ActiveXPosh and Enable-Mailbox
success = ActiveXPosh.Init(vbTrue)
Otherwise yor profile will not be executed, which most likely contains the snapin(s) you need.
Alex
Otherwise yor profile will not be executed, which most likely contains the snapin(s) you need.
Alex
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
ActiveXPosh and Enable-Mailbox
Thanks for your help Alex.
Unfortunately, when I changed it to vbTrue and ran the
script I got the message "Init failed"
My snapin for Exchange which is:
Add-PSSnapIn Microsoft.Exchange.Management.PowerShell.Admin
is already loaded. And I can run Enable-Mailbox directly in
Powershell and the mailbox gets created so everything is working there.
I'm just stuck on getting ActiveXPosh to execute it for me.
Any other ideas?
mrove2008-12-07 17:22:04
Unfortunately, when I changed it to vbTrue and ran the
script I got the message "Init failed"
My snapin for Exchange which is:
Add-PSSnapIn Microsoft.Exchange.Management.PowerShell.Admin
is already loaded. And I can run Enable-Mailbox directly in
Powershell and the mailbox gets created so everything is working there.
I'm just stuck on getting ActiveXPosh to execute it for me.
Any other ideas?
mrove2008-12-07 17:22:04
- Alexander Riedel
- Posts: 6818
- Joined: Tue May 29, 2007 4:43 pm
ActiveXPosh and Enable-Mailbox
Ok, run Init(VBFalse)
and add this line:
ActiveXPosh.Execute("Add-PSSnapIn Microsoft.Exchange.Management.PowerShell.Admin")
You are most likely running a specialized shell that already loads that snapin.
and add this line:
ActiveXPosh.Execute("Add-PSSnapIn Microsoft.Exchange.Management.PowerShell.Admin")
You are most likely running a specialized shell that already loads that snapin.
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
ActiveXPosh and Enable-Mailbox
Yep, that works!
I swear I tried that yesterday but I was at it
(and the AD user account script I am embedding it in)
for about 6 hours so maybe I didn't get it all in the
right sequence.
I took the Add-PSSnapIn out of the script and was invoking it
via Powershell directly and the script never worked.
Anyways, it is working now.
Thank you very much for taking time out to assist me!
I appreciate it.
I swear I tried that yesterday but I was at it
(and the AD user account script I am embedding it in)
for about 6 hours so maybe I didn't get it all in the
right sequence.
I took the Add-PSSnapIn out of the script and was invoking it
via Powershell directly and the script never worked.
Anyways, it is working now.
Thank you very much for taking time out to assist me!
I appreciate it.