protected override void ProcessRecord() { PwshCode pwsh = new PwshCode(); try { Prefix = Prefix == "None" ? "" : Prefix; string Output = String.IsNullOrEmpty(Secret) ? pwsh.UndoPwshCode(PwshCode, Prefix) : pwsh.UndoPwshCode(PwshCode, Secret, Prefix); if (!Output.Contains("##IsString##")) { PSObject DeserializedOutput = PSObject.AsPSObject(PSSerializer.Deserialize(Output)); WriteObject(DeserializedOutput); } else { WriteObject(Output.Replace("##IsString##", "")); } } catch { WriteObject("Don't think so! ;)"); } }
protected override void ProcessRecord() { PwshCode pwsh = new PwshCode(); string ObjectType = InputObject.ImmediateBaseObject.GetType().FullName; string Input; switch (ObjectType) { case "System.String": Input = InputObject.ToString() + "##IsString##"; break; default: Input = PSSerializer.Serialize(InputObject); break; } Prefix = Prefix == "None" ? "" : Prefix; string pwshCode = String.IsNullOrEmpty(Secret) ? pwsh.GetPwshCode(Input, Prefix) : pwsh.GetPwshCode(Input, Secret, Prefix); WriteObject(pwshCode); }