protected override void ProcessRecord() { base.ProcessRecord(); var ctx = base.Context; Web web = ctx.Site.OpenWeb(Web.Read()); SPOContentType contentType = null; if (List == null) { contentType = ContentType.Read(web); } else { SPOList list = List.Read(web, false); contentType = ContentType.Read(list.List); } if (contentType == null) { throw new ArgumentException("Unable to locate the specified content type."); } if (base.ShouldProcess(contentType.Name, "Remove Content Type")) { contentType.Delete(); } }