public Collection <T> RunPSCommand <T>(PSCommand command) where T : class { ErrorRecord errorRecord = null; string commandString = AnchorRunspaceProxy.GetCommandString(command); try { Collection <T> result = this.RunPSCommand <T>(command, out errorRecord); if (errorRecord == null) { this.Context.Logger.Log(MigrationEventType.Verbose, "Running PS command {0}", new object[] { commandString }); return(result); } } catch (ParameterBindingException ex) { this.HandleException <T>(commandString, ex); } catch (CmdletInvocationException ex2) { this.HandleException <T>(commandString, ex2); } AnchorUtil.AssertOrThrow(errorRecord != null, "expect to have an error at this point", new object[0]); if (errorRecord.Exception != null) { this.HandleException <T>(commandString, errorRecord.Exception); } throw new MigrationPermanentException(ServerStrings.MigrationRunspaceError(commandString, errorRecord.ToString())); }
public Collection <T> RunPSCommand <T>(PSCommand command, out ErrorRecord error) { PowerShellProxy powerShellProxy = null; Collection <T> result = AnchorUtil.RunTimedOperation <Collection <T> >(this.Context, delegate() { powerShellProxy = new PowerShellProxy(this.runspaceProxy, command); return(powerShellProxy.Invoke <T>()); }, AnchorRunspaceProxy.GetCommandString(command)); if (powerShellProxy.Failed) { error = powerShellProxy.Errors[0]; return(null); } error = null; return(result); }
public static AnchorRunspaceProxy CreateRunspaceForDatacenterAdmin(AnchorContext context, ADObjectId ownerId) { AnchorUtil.ThrowOnNullArgument(ownerId, "ownerId"); return(AnchorRunspaceProxy.CreateRunspaceForDatacenterAdmin(context, ownerId.ToString())); }