Lerch Web Wiki

Random, erratic, no responsibility is taken for the correctness of this information

User Tools

Site Tools


powershell:basics:objects

Working with Objects

Sample-Object.ps1
$csharp = @'
namespace PoShWS {    
    public enum FarbPalette {
        Schwarz,
        Weiss,
        Rot,
        Gelb,
        Gruen,
        Blau
    }
 
    public enum UserAccountControlFlag {
        EMPTY = 0x0,
        SCRIPT = 0x0001,
        ACCOUNTDISABLE = 0x0002,
        HOMEDIR_REQUIRED = 0x0008,
        LOCKOUT = 0x0010,
        PASSWD_NOTREQD = 0x0020,
        PASSWD_CANT_CHANGE = 0x0040,
        ENCRYPTED_TEXT_PWD_ALLOWED = 0x0080,
        TEMP_DUPLICATE_ACCOUNT = 0x0100,
        NORMAL_ACCOUNT = 0x0200,
        INTERDOMAIN_TRUST_ACCOUNT = 0x0800,
        WORKSTATION_TRUST_ACCOUNT = 0x1000,
        SERVER_TRUST_ACCOUNT = 0x2000,
        DONT_EXPIRE_PASSWORD = 0x10000,
        MNS_LOGON_ACCOUNT = 0x20000,
        SMARTCARD_REQUIRED = 0x40000,
        TRUSTED_FOR_DELEGATION = 0x80000,
        NOT_DELEGATED = 0x100000,
        USE_DES_KEY_ONLY = 0x200000,
        DONT_REQ_PREAUTH = 0x400000,
        PASSWORD_EXPIRED = 0x800000,
        TRUSTED_TO_AUTH_FOR_DELEGATION = 0x1000000,
        PARTIAL_SECRETS_ACCOUNT = 0x04000000,
    }
 
    public class ObjectSample {
        public int Zahl { get; set; }
        public string Text { get; set; }
        public FarbPalette Farbe { get; set; }
        public UserAccountControlFlag UAC { get; set; }
    }
}
'@
 
Add-Type -Language CSharpVersion3 -TypeDefinition $csharp
Object-SampleWithInheritance.ps1
$csharp = @'
using System;
public class Animal
{
    public int Legs { get; set; }
    public virtual void Greet()
    {
        Console.WriteLine("Hello, I'm some sort of animal!");
    }
}
 
public class Dog : Animal
{
    public override void Greet()
    {
        Console.WriteLine("Hello, I'm a dog!");
    }
}
 
'@
 
Add-Type -Language CSharpVersion3 -TypeDefinition $csharp
This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
powershell/basics/objects.txt · Last modified: 2017/02/21 11:20 by marcus