header
header Register : : Login header
header
divider
menuleft
menuright
submenu
left

[August 25th, 2008] Check the home page regarding PowerShell related news from a brand new sponsor: Idera

error Executing powershell in asp.net in server
Last Post 26 Sep 2008 05:36 PM by nine. 2 Replies.
Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
nineUser is Offline
New Member
New Member
Posts:2

--
27 Aug 2008 08:03 AM  

Dear

i'm trying to execute Exchange PS command in asp.net

it's working fine when i run this command from my local machine

this is url http://localhost:1975/meABC/test.aspx

but wehn i run this code inside the server i got this error http://me.ABC.com.sa/test.aspx

Server Error in '/PS_Enable' Application.

Database "ABCCNTMSG02\ABCCNTMSG02-SG7\ABCCNTMSG02-DB7" was not found. Please make sure you have typed it correctly.

here is my code

'references  to work with Powershell command
Imports System.Management.Automation
Imports System.Management.Automation.Host
Imports System.Management.Automation.Runspaces
'references  to work with Powershell command
Imports System.Collections.Generic
Imports System.Collections.ObjectModel
 
Partial Class _Default
    Inherits System.Web.UI.Page
   Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim rsConfig As RunspaceConfiguration = RunspaceConfiguration.Create
        Dim snapInException As PSSnapInException = Nothing
        Dim info As PSSnapInInfo = rsConfig.AddPSSnapIn("Microsoft.Exchange.Management.PowerShell.Admin", snapInException)
        Dim myRunSpace As Runspace = RunspaceFactory.CreateRunspace(rsConfig)
        myRunSpace.Open()
        Dim pipeLine As Pipeline = myRunSpace.CreatePipeline
        Dim vid As String = "ABC.corp\uid"
        Dim PrimarySMTP As String = "uid.c@ABC.com.sa"
        Dim valias As String = "uid"
        Dim vdb As String = "CN=ABCCNTMSG02-DB7,CN=ABCCNTMSG02-SG7,CN=InformationStore,CN=ABCCNTMSG02,CN=Servers,CN=Exchange Administrative Group (FYDIBOHF23SPDLT),CN=Administrative Groups,CN=ABC,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=root,DC=ad"
        Dim EMSCmd As Command = New Command("Enable-Mailbox")
        EMSCmd.Parameters.Add("DomainController", "ABCCNTDC21")
        EMSCmd.Parameters.Add("Identity", vid)
        EMSCmd.Parameters.Add("Alias", valias)
        EMSCmd.Parameters.Add("Database", vdb)
        EMSCmd.Parameters.Add("PrimarySmtpAddress", PrimarySMTP)
        pipeLine.Commands.Add(EMSCmd)
        Dim cmdData1 As Collection(Of PSObject) = pipeLine.Invoke()
    End Sub
End Class
 

when i added this line to see more error details Response.Write("IsOpen: " & pipeLine.Error.IsOpen)

 I got this error IsOpen: False

then after searchinig in many articles i've read this Post from asp.net forum and i follow the steps but still same problem

http://forums.asp.net/p/1272317/2408799.aspx

one i change DefaultAppPool identity to my account and try to browse web site

I got error Service Unavaliable

Plz help me to to solve this issue so i can sleep good

Thanks in advance

 

KarlMitschkeUser is Offline
Basic Member
Basic Member
Posts:161

--
27 Aug 2008 09:13 PM  
Nine;
Did you see my posts on this? (Particularilly the first one)
http://powershellcommunity.org/Forums/tabid/54/forumid/3/postid/524/view/topic/Default.aspx
http://powershellcommunity.poshcode.org/505 - MailboxTasks.aspx
http://powershellcommunity.poshcode.org/506 - MailboxTasks.aspx.cs
http://powershellcommunity.poshcode.org/507 - MailboxConfirm.aspx
http://powershellcommunity.poshcode.org/508 - MailboxConfirm.aspx.cs
http://powershellcommunity.poshcode.org/509 - MailboxTaskResults.aspx
http://powershellcommunity.poshcode.org/510 - MailboxTaskResults.aspx.cs
nineUser is Offline
New Member
New Member
Posts:2

--
26 Sep 2008 05:36 PM  
Dear
I solved this issue with easy step

by adding the impersonation user to identity in application pool

and add this user to WPG group in hosting system

WPG(Work Proccess Group)

that's it

Thanks for all to all answers

NiNe
You are not authorized to post a reply.

Active Forums 4.1
right
   
footer Sponsored by Quest Software • SAPIEN Technologies • ShellTools, LLC • Microsoft Windows Server 2008 footer
footer