PoshCode Archive  Artifact [efdcb1af44]

Artifact efdcb1af447213c174ea793453b0dd8d47278ee0851324789d309174c2c89b29:

  • File IADsDNWithBinary-Cmdlet.ps1 — part of check-in [c66e244c23] at 2018-06-10 12:56:35 on branch trunk — I cooked this up to configure OCS user policy, but it should work for other attributes of this type as well. (user: unknown size: 2703)

# encoding: ascii
# api: csharp
# title: IADsDNWithBinary Cmdlet
# description: I cooked this up to configure OCS user policy, but it should work for other attributes of this type as well.
# version: 0.1
# type: class
# license: CC0
# x-poshcode-id: 1168
# x-archived: 2009-06-27T19:48:03
#
#
//Adapted from code @ http://mow001.blogspot.com/2006/01/msh-snap-in-to-translate.html Thanks!

using System;
using System.ComponentModel;
using System.Management.Automation;
using System.Reflection;
using System.Diagnostics;


namespace space
{
    // This class defines the properties of a snap-in 
    [RunInstaller(true)]
    public class readIADsDNWithBinary : PSSnapIn
    {
        /// Creates instance of Snapin class. 
        public readIADsDNWithBinary() : base() { }
        ///Snapin name is used for registration 
        public override string Name
        { get { return "readIADsDNWithBinary"; } }
        /// Gets description of the snap-in.  
        public override string Description
        { get { return "Reads a IADsDNWithBinary"; } }
        public override string Vendor
        { get { return "Andrew"; } } 

    }
    /// Gets a IADsDNWithBinary
    [Cmdlet("Read", "IADsDNWithBinary")]
    public class readIADsDNWithBinaryCommand : Cmdlet
    {
        [Parameter(Position = 0, Mandatory = true)]
        public object DNWithBinary
        {
            get { return DNWithBin; }
            set { DNWithBin = value; }
        }

        private object DNWithBin;

        protected override void EndProcessing()
        {
            ActiveDs.IADsDNWithBinary DNB = (ActiveDs.IADsDNWithBinary)DNWithBin;
            ActiveDs.DNWithBinary boink = new ActiveDs.DNWithBinaryClass();
            boink.BinaryValue = (byte[])DNB.BinaryValue;
            boink.DNString = DNB.DNString;
            WriteObject(boink);
        }
    }
    /// Sets a IADsDNWithBinary
    [Cmdlet("Write", "IADsDNWithBinary")]
    public class writeIADsDNWithBinaryCommand : Cmdlet
    {
        [Parameter(Mandatory = true)]
        public byte[] Bin
        {
            get { return bin; }
            set { bin = value; }
        }
        private byte[] bin;

        [Parameter(Mandatory = true)]
        public string DN
        {
            get { return dn; }
            set { dn = value; }
        }
        private string dn;
          

        protected override void EndProcessing()
        {
            ActiveDs.DNWithBinary boink2 = new ActiveDs.DNWithBinaryClass();
            boink2.BinaryValue = bin;
            boink2.DNString = dn;
            WriteObject(boink2);
        }
    }    
}