Click here to Skip to main content
15,889,462 members
Home / Discussions / C#
   

C#

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