Click here to Skip to main content
15,893,790 members
Home / Discussions / C#
   

C#

 
AnswerRe: Error: External table is not in the expected format Pin
Richard MacCutchan28-Jul-13 22:29
mveRichard MacCutchan28-Jul-13 22:29 
GeneralRe: Error: External table is not in the expected format Pin
NarVish28-Jul-13 23:49
NarVish28-Jul-13 23:49 
GeneralRe: Error: External table is not in the expected format Pin
Richard MacCutchan29-Jul-13 0:01
mveRichard MacCutchan29-Jul-13 0:01 
GeneralRe: Error: External table is not in the expected format Pin
NarVish29-Jul-13 0:14
NarVish29-Jul-13 0:14 
GeneralRe: Error: External table is not in the expected format Pin
Richard MacCutchan29-Jul-13 0:20
mveRichard MacCutchan29-Jul-13 0:20 
GeneralRe: Error: External table is not in the expected format Pin
NarVish29-Jul-13 0:52
NarVish29-Jul-13 0:52 
QuestionScrollViewer adjusting HorizontalOffset in VirtualizingStackPanel Pin
Revolty28-Jul-13 3:39
Revolty28-Jul-13 3:39 
QuestionNeed help to use powershell script with two foreach in c# Pin
Member 981625927-Jul-13 19:37
Member 981625927-Jul-13 19: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 1:04
mveRichard MacCutchan28-Jul-13 1:04 
QuestionHow to use powershell hash table in c#. Pin
Member 981625927-Jul-13 19:36
Member 981625927-Jul-13 19:36 
QuestionDisplay RichTextBox string in RDLC report Pin
cdpsource25-Jul-13 23:38
cdpsource25-Jul-13 23:38 
AnswerRe: Display RichTextBox string in RDLC report Pin
Richard Deeming26-Jul-13 1:44
mveRichard Deeming26-Jul-13 1:44 
GeneralRe: Display RichTextBox string in RDLC report Pin
cdpsource26-Jul-13 2:10
cdpsource26-Jul-13 2:10 
GeneralRe: Display RichTextBox string in RDLC report Pin
Richard Deeming26-Jul-13 2:32
mveRichard Deeming26-Jul-13 2:32 
Questionabout browsers Pin
DTSFI25-Jul-13 22:47
DTSFI25-Jul-13 22:47 
AnswerRe: about browsers Pin
Dave Kreskowiak26-Jul-13 2:44
mveDave Kreskowiak26-Jul-13 2:44 
QuestionSpeech Recgnition Pin
Pavan Patle25-Jul-13 19:06
Pavan Patle25-Jul-13 19:06 
AnswerRe: Speech Recgnition PinPopular
Richard MacCutchan25-Jul-13 21:23
mveRichard MacCutchan25-Jul-13 21:23 
AnswerRe: Speech Recgnition Pin
Blue_Boy25-Jul-13 21:48
Blue_Boy25-Jul-13 21:48 
GeneralRe: Speech Recgnition Pin
Keith Barrow25-Jul-13 23:24
professionalKeith Barrow25-Jul-13 23:24 
GeneralRe: Speech Recgnition Pin
Blue_Boy26-Jul-13 2:13
Blue_Boy26-Jul-13 2:13 
GeneralRe: Speech Recgnition Pin
Keith Barrow26-Jul-13 2:22
professionalKeith Barrow26-Jul-13 2:22 
SuggestionMy Vote of 1 PinPopular
Keith Barrow25-Jul-13 23:32
professionalKeith Barrow25-Jul-13 23:32 
AnswerRe: Speech Recgnition Pin
Amir Mohammad Nasrollahi29-Jul-13 4:28
professionalAmir Mohammad Nasrollahi29-Jul-13 4:28 
QuestionC# winfoms application with sql server database (online) ? Pin
Member 996694125-Jul-13 12:57
Member 996694125-Jul-13 12: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.