Last active
August 29, 2015 13:57
-
-
Save nshenoy/9530080 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
InitialSessionState state = InitialSessionState.CreateDefault(); | |
state.ImportPSModule(new string[] { "DistributedCacheAdministration", "DistributedCacheConfiguration" }); | |
state.ThrowOnRunspaceOpenError = true; | |
using(Runspace rs = RunspaceFactory.CreateRunspace(state)) | |
{ | |
rs.Open(); | |
using(Pipeline pipeline = rs.CreatePipeline()) | |
{ | |
Command command = new Command("Use-CacheCluster"); | |
command.Parameters.Add(new CommandParameter("Provider", "System.Data.SqlClient")); | |
command.Parameters.Add(new CommandParameter("ConnectionString", "Data Source=.\\SQLEXPRESS;Initial Catalog=AppFabric;Integrated Security=True")); | |
pipeline.Commands.Add(command); | |
Trace.WriteLine(string.Format("Invoking: {0} {1}", | |
command.CommandText, | |
string.Join(" ", command.Parameters.Select(p => string.Format("-{0} \"{1}\"", p.Name, p.Value))))); | |
pipeline.Invoke(); | |
} | |
Trace.WriteLine("I expect to see this line and all other traces after this."); | |
} | |
Trace.WriteLine("Ending program"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment