1

I wish to create an array of events in a calendar. Both Event and Calendar are Objects. I couldn't find any documentation for the creation of a simple array in an Object.

1 Answer 1

3

How about something like this -

$cal = New-Object -Type PsObject -Prop @{
    Year = 2013
    Events = @()
}

$event = New-Object -Type PsObject -Prop @{
    Date = [DateTime] "2013-02-14"
    Name = "Valentines Day"
}

$cal.Events += $event

If you have a predefined calendar objects which doesn't have a property to store events you can use Add-Member to attach a new property and store an array in there.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.