2023-11-16 15:20:50 -06:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Management.Automation;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading.Tasks;
|
2024-06-11 21:43:12 -05:00
|
|
|
|
using YamlDotNet.Serialization.NamingConventions;
|
|
|
|
|
|
using YamlDotNet.Serialization;
|
2023-11-16 15:20:50 -06:00
|
|
|
|
|
|
|
|
|
|
namespace LANCommander.PowerShell.Cmdlets
|
|
|
|
|
|
{
|
|
|
|
|
|
[Cmdlet(VerbsData.ConvertTo, "SerializedBase64")]
|
|
|
|
|
|
[OutputType(typeof(object))]
|
|
|
|
|
|
public class ConvertToSerializedBase64Cmdlet : Cmdlet
|
|
|
|
|
|
{
|
|
|
|
|
|
[Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true)]
|
|
|
|
|
|
public object Input { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
protected override void ProcessRecord()
|
|
|
|
|
|
{
|
2024-06-11 21:43:12 -05:00
|
|
|
|
var serializer = new SerializerBuilder()
|
|
|
|
|
|
.WithNamingConvention(new PascalCaseNamingConvention())
|
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
|
|
var output = Convert.ToBase64String(Encoding.UTF8.GetBytes(serializer.Serialize(Input)));
|
2023-11-16 15:20:50 -06:00
|
|
|
|
|
|
|
|
|
|
WriteObject(output);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|