protected override void ProcessRecord() { var connectionToShare = IcsManager.FindConnectionByIdOrName(Shared_connection); if (connectionToShare == null) { WriteError(new ErrorRecord(new PSArgumentException("Connection not found"), "", ErrorCategory.InvalidArgument, Shared_connection)); return; } var homeConnection = IcsManager.FindConnectionByIdOrName(Home_connection); if (homeConnection == null) { WriteError(new ErrorRecord(new PSArgumentException("Connection not found"), "", ErrorCategory.InvalidArgument, Home_connection)); return; } var currentShare = IcsManager.GetCurrentlySharedConnections(); if (currentShare.Exists) { WriteWarning("Internet Connection Sharing is already enabled: " + currentShare.ToString()); if (!force) { WriteError(new ErrorRecord(new PSInvalidOperationException("Please disable existing ICS if you want to enable it for other connections, or set the force flag to true"), "", ErrorCategory.InvalidOperation, null)); return; } Console.WriteLine("Sharing will be disabled first."); } IcsManager.ShareConnection(connectionToShare, homeConnection); }
protected override void ProcessRecord() { IcsManager.ShareConnection(null, null); }