Example #1
0
 /// <summary>
 /// Executes this instance.
 /// </summary>
 /// <returns></returns>
 public PsExecutionResult Execute()
 {
     PsExecutionResult result = new PsExecutionResult(); PipelineExecutor pexec = new PipelineExecutor(); string opResult = string.Empty;  try { result.ResultMessage = pexec.RunScriptReturnStr((HyperV.Definitions.HypervCommands[(int)this.Command]).ToString(), this._Parameters, this._iss); result.Success = true; }             catch (Exception ex) { result.Success = false; result.ResultMessage = string.Format("Error executing the command {0} for the VM {1} with the parameters {2}", this.Command.ToString(), this._VmName, string.Join(",", _Parameters.Select(kv => kv.Key.ToString() + "=" + kv.Value.ToString()).ToArray())); result.Exception = ex; ExceptionManager.HandleException(ex); }             finally { pexec = null; } return result;
 }
 /// <summary>
 /// Get the vhd path for a given named vm
 /// </summary>
 /// <param name="vmName">Name of the VM</param>
 /// <returns></returns>
 public string GetVHDPath( string vmName)
 {
     PipelineExecutor pexec = new PipelineExecutor();  Dictionary<string, object> getVHDPathParameters = new Dictionary<string, object>(); getVHDPathParameters.Add("VMName", vmName);  ICollection<PSObject> results = pexec.RunScript(".\\PsScripts\\GetVHDPath.ps1", getVHDPathParameters, this._iss);  if (null != results && null != results.ElementAt(2))  return results.ElementAt(2).ToString();  return String.Empty;
 }