Click here to Skip to main content
15,174,232 members
Home / Discussions / C#
   

C#

 
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 
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 
Hi All,

I want to use the below powershell command in c# and get the desired output.

Powershell script:

foreach($a in get-mailbox){get-activesyncdevicestatistics -mailbox $a.identity | Select DeviceFriendlyName, Devicetype, DeviceUserAgent,@{Name="User Name";expression={$a.displayname}}}

------------------------------------------------------------------------

I have made the code as below, but need your help to work on Select part with hash table. Please let me know, how I can include the "Select DeviceFriendlyName, Devicetype, DeviceUserAgent,@{Name="User Name";expression={$a.displayname}}}" in the below code.

----------------------------------------------------------------------------

C# code:

Collapse | Copy 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();
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 
AnswerRe: C# winfoms application with sql server database (online) ? Pin
Ron Beyer25-Jul-13 14:08
professionalRon Beyer25-Jul-13 14:08 
AnswerRe: C# winfoms application with sql server database (online) ? Pin
Mycroft Holmes25-Jul-13 14:59
professionalMycroft Holmes25-Jul-13 14:59 

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.