Click here to Skip to main content
15,173,031 members
Home / Discussions / C#
   

C#

 
AnswerRe: Error: External table is not in the expected format Pin
Richard MacCutchan28-Jul-13 23:29
mveRichard MacCutchan28-Jul-13 23:29 
GeneralRe: Error: External table is not in the expected format Pin
NarVish29-Jul-13 0:49
MemberNarVish29-Jul-13 0:49 
GeneralRe: Error: External table is not in the expected format Pin
Richard MacCutchan29-Jul-13 1:01
mveRichard MacCutchan29-Jul-13 1:01 
GeneralRe: Error: External table is not in the expected format Pin
NarVish29-Jul-13 1:14
MemberNarVish29-Jul-13 1:14 
GeneralRe: Error: External table is not in the expected format Pin
Richard MacCutchan29-Jul-13 1:20
mveRichard MacCutchan29-Jul-13 1:20 
GeneralRe: Error: External table is not in the expected format Pin
NarVish29-Jul-13 1:52
MemberNarVish29-Jul-13 1:52 
QuestionScrollViewer adjusting HorizontalOffset in VirtualizingStackPanel Pin
Revolty28-Jul-13 4:39
MemberRevolty28-Jul-13 4:39 
QuestionNeed help to use powershell script with two foreach in c# Pin
Member 981625927-Jul-13 20:37
MemberMember 981625927-Jul-13 20:37 
Hi All,

I want to use the below powershell script in c#. The script is with two foreach loop and the 2nd foreach loop uses add-member to add the value that is part of $mailbox variable. I managed to write c# code to work upto first foreach. I need help to complete the c# code with 2nd foreach loop and using the value of $mailbox.

Powershell Script :

ForEach ($Mailbox in Get-Mailbox) {Get-ActiveSyncDeviceStatistics -Mailbox $Mailbox.Identity –ErrorAction SilentlyContinue | Select DeviceFriendlyName, Devicetype, DeviceUserAgent | ForEach-Object { $_ | Add-Member –MemberType NoteProperty -Name "MailboxIdentity" -value $Mailbox}}

I managed to go upto,

c# code:
PowerShellpowershell = PowerShell.Create();
PSCommandcommand = newPSCommand();
command.AddCommand("Get-Mailbox");
command.AddCommand("where-object");
command.AddParameter("Filterscript", scriptBlock.Create("!$_.name.startswith(\"DiscoverySearchMailbox\")"));
powershell.Commands = command;
powershell.Runspace = CreateRunSpace.GetRunSpace();
varresult = powershell.Invoke();

 
PSCommandcommand1 = newPSCommand();
command1.AddCommand("write-output");
command1.AddParameter("InputObject", result);
command1.AddCommand("Foreach-Object");
command1.AddParameter("Process", ScriptBlock.Create("Get-ActiveSyncDeviceStatistics -Mailbox $_.Identity"));
powershell.Commands = command1;
powershell.Runspace = CreateRunSpace.GetRunSpace();
var result1 = powershell.Invoke();


I'm stuck at 2nd foreach loop to add-member while adding the output of get-mailbox. Appreciate your help and suggestions. Thank you.
AnswerRe: Need help to use powershell script with two foreach in c# Pin
Richard MacCutchan28-Jul-13 2:04
mveRichard MacCutchan28-Jul-13 2:04 
QuestionHow to use powershell hash table in c#. Pin
Member 981625927-Jul-13 20:36
MemberMember 981625927-Jul-13 20:36 
QuestionDisplay RichTextBox string in RDLC report Pin
cdpsource26-Jul-13 0:38
Membercdpsource26-Jul-13 0:38 
AnswerRe: Display RichTextBox string in RDLC report Pin
Richard Deeming26-Jul-13 2:44
mveRichard Deeming26-Jul-13 2:44 
GeneralRe: Display RichTextBox string in RDLC report Pin
cdpsource26-Jul-13 3:10
Membercdpsource26-Jul-13 3:10 
GeneralRe: Display RichTextBox string in RDLC report Pin
Richard Deeming26-Jul-13 3:32
mveRichard Deeming26-Jul-13 3:32 
Questionabout browsers Pin
DTSFI25-Jul-13 23:47
MemberDTSFI25-Jul-13 23:47 
AnswerRe: about browsers Pin
Dave Kreskowiak26-Jul-13 3:44
mveDave Kreskowiak26-Jul-13 3:44 
QuestionSpeech Recgnition Pin
Pavan Patle25-Jul-13 20:06
MemberPavan Patle25-Jul-13 20:06 
AnswerRe: Speech Recgnition Pin
Richard MacCutchan25-Jul-13 22:23
mveRichard MacCutchan25-Jul-13 22:23 
AnswerRe: Speech Recgnition Pin
Blue_Boy25-Jul-13 22:48
MemberBlue_Boy25-Jul-13 22:48 
GeneralRe: Speech Recgnition Pin
Keith Barrow26-Jul-13 0:24
professionalKeith Barrow26-Jul-13 0:24 
GeneralRe: Speech Recgnition Pin
Blue_Boy26-Jul-13 3:13
MemberBlue_Boy26-Jul-13 3:13 
GeneralRe: Speech Recgnition Pin
Keith Barrow26-Jul-13 3:22
professionalKeith Barrow26-Jul-13 3:22 
SuggestionMy Vote of 1 Pin
Keith Barrow26-Jul-13 0:32
professionalKeith Barrow26-Jul-13 0:32 
AnswerRe: Speech Recgnition Pin
Amir Mohammad Nasrollahi29-Jul-13 5:28
professionalAmir Mohammad Nasrollahi29-Jul-13 5:28 
QuestionC# winfoms application with sql server database (online) ? Pin
Member 996694125-Jul-13 13:57
MemberMember 996694125-Jul-13 13:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.