Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Mar 06, 2013 01:26 PM by blentoza
0 Points
5 Posts
Mar 06, 2013 01:26 PM|LINK
Hi together
I have following powershell script implemented on my page.
param($MailboxName)
$Cred = New-Object System.Management.Automation.PSCredential "username",(get-content "C:\PSScripts\passwd.txt" | convertto-securestring)
$Exsession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http://ExchangeServer/PowerShell/" -Authentication Kerberos -Credential $Cred Import-PSSession $Exsession -AllowClobber | Out-Null if(!$MailboxName -eq "")
{
get-mailbox -identity $MailboxName | select *
}
Powershell Script is implemented on my page on following way:
protected void GetMailboxButton_Submit(object sender, EventArgs e)
string argument = MailboxName.Text;
string script = @"C:\inetpub\wwwroot\PSScripts\GetMailbox.ps1 -MailboxName @argument";
script = script.Replace("@argument", argument);
PowerShell psExec = PowerShell.Create();
psExec.AddScript(script);
psExec.Invoke();
If i start the page in visual studio everything is working fine and i get desired mailbox.
But if i start it in IIS and asp.net i receive followng error message.
"Key not valid for use in specified state.
Object reference not set to an instance of an object. "
Seems to be exchange connecting problem via iis.
Do you have any idea what it could be.
As already mentioned i can start it in visual studio fine and connection to my exchange server from powershellscript is working fine.
Please help
Kind regards
blentoza
0 Points
5 Posts
Exchange cmdlet call via powershell script
Mar 06, 2013 01:26 PM|LINK
Hi together
I have following powershell script implemented on my page.
param($MailboxName)
$Cred = New-Object System.Management.Automation.PSCredential "username",(get-content "C:\PSScripts\passwd.txt" | convertto-securestring)
$Exsession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http://ExchangeServer/PowerShell/" -Authentication Kerberos -Credential $Cred Import-PSSession $Exsession -AllowClobber | Out-Null if(!$MailboxName -eq "")
{
get-mailbox -identity $MailboxName | select *
}
Powershell Script is implemented on my page on following way:
protected void GetMailboxButton_Submit(object sender, EventArgs e)
{
string argument = MailboxName.Text;
string script = @"C:\inetpub\wwwroot\PSScripts\GetMailbox.ps1 -MailboxName @argument";
script = script.Replace("@argument", argument);
PowerShell psExec = PowerShell.Create();
psExec.AddScript(script);
psExec.Invoke();
}
If i start the page in visual studio everything is working fine and i get desired mailbox.
But if i start it in IIS and asp.net i receive followng error message.
"Key not valid for use in specified state.
Object reference not set to an instance of an object. "
Seems to be exchange connecting problem via iis.
Do you have any idea what it could be.
As already mentioned i can start it in visual studio fine and connection to my exchange server from powershellscript is working fine.
Please help
Kind regards