5.4. Creating new messages¶
5.4.1. Creating an IDERI note message using parameters¶
One way to create a new IDERI note message in PowerShell is to use the New-iNoteMessage CmdLet. We can use it by specifying all mandatory and optional information for a new message using its parameters. To get a list of all the parameters the CmdLet supports, we can use the Get-Help CmdLet. The result set from this command will be quite exhaustive, but will give you a complete overview of the available functionality.
PS> Get-Help -Name New-iNoteMessage -Parameter *
We now actually create a new message: The message should be valid from now on for two hours, should have a priority of ‘Information’ and should be addressed to the Active Directory® users with the username Albert.Tross, Eva.Smith and Arno.Nym. For this purpose, we execute the following command:
PS> New-iNoteMessage -Text "My message from powershell." `
-StartTime (Get-Date) `
-EndTime (Get-Date).AddHours(2) `
-Priority INFORMATION `
-Recipient "Albert.Tross","Eva.Smith","Arno.Nym" `
-ShowPopup
Index : 2
Text : My message from powershell.
Priority : Information
StartTime : 8/3/2023 8:28:52 AM
EndTime : 8/3/2023 10:28:52 AM
LinkText :
LinkTarget :
ShowLinkMaximized : False
Recipient : {NOTE\eva.smith, NOTE\albert.tross, NOTE\Arno.Nym}
Exclude : {}
AddressingMode : UserOnly
ShowPopup : True
ShowTicker : False
ShowFullscreen : False
ShowFullscreenAndLock : False
NotifyReceive : False
NotifyAcknowledge : False
ShowOnWinLogon : False
ShowOnWinLogonOnly : False
HomeOfficeUsersOnly : False
HomeOfficeUsersExclude : False
After the message has been created successfully, the message object representing the message will be returned.
5.4.2. Creating a new IDERI note message using a predefined object¶
Another way to add a new message is by specifying a new message object first and then passing it to New-iNoteMessage.
In the following example we want to create a message with the priority of ‘Warning’ that is valid from now on for one hour and is addressed to the Active Directory® user Albert.Tross and the group GRP_IDERI_IT. The message should only be displayed in the IDERI note Ticker and should be sent to both users and computers.
PS> $newMsg = [Ideri.Note.Message]::new($IDERInoteServerSession)
PS> $newMsg.Text = "Another message from PS created using an object."
PS> $newMsg.Priority = [Ideri.Note.Priority]::Warning
PS> $newMsg.StartTime = (Get-Date)
PS> $newMsg.EndTime = (Get-Date).AddHours(1)
PS> $newMsg.AddRecipient(@("albert.tross","GRP_IDERI_IT"))
PS> $newMsg.ShowTicker = $true
PS> $newMsg.AddressingMode = [Ideri.Note.AddressingMode]::UserAndComputer
PS>
PS> New-iNoteMessage -MessageObject $newMsg
Index : 3
Text : Another message from PS created using an object.
Priority : Warning
StartTime : 8/3/2023 8:32:24 AM
EndTime : 8/3/2023 9:32:24 AM
LinkText :
LinkTarget :
ShowLinkMaximized : False
Recipient : {NOTE\albert.tross, NOTE\GRP_IDERI_IT}
Exclude : {}
AddressingMode : UserAndComputer
ShowPopup : False
ShowTicker : True
ShowFullscreen : False
ShowFullscreenAndLock : False
NotifyReceive : False
NotifyAcknowledge : False
ShowOnWinLogon : False
ShowOnWinLogonOnly : False
HomeOfficeUsersOnly : False
HomeOfficeUsersExclude : False
The above example demonstrates the creation of a new object of type Ideri.Note.Message whose properties are afterwards set to their desired values before finally passing the object to the New-iNoteMessage CmdLet in order to create the message.
5.4.3. Copying an existing message¶
The parameter ‘-MessageObject’ of New-iNoteMessage also accepts piped values. So if you e.g. want to copy an existing message and create a new one from it, you can use the Get-iNoteMessage CmdLet and pipe its output to New-iNoteMessage.
PS> Get-iNoteMessage -Index 1 | New-iNoteMessage
Index : 4
Text : This is a test message.
Priority : Information
StartTime : 8/3/2023 8:15:00 AM
EndTime : 8/3/2023 2:30:00 PM
LinkText :
LinkTarget :
ShowLinkMaximized : False
Recipient : {NOTE\eva.smith, NOTE\albert.tross}
Exclude : {}
AddressingMode : UserAndComputer
ShowPopup : True
ShowTicker : False
ShowFullscreen : False
ShowFullscreenAndLock : False
NotifyReceive : False
NotifyAcknowledge : True
ShowOnWinLogon : False
ShowOnWinLogonOnly : False
HomeOfficeUsersOnly : False
HomeOfficeUsersExclude : False
The above example shows that the content of the message with index 1 has been copied and a new message with index 4 has been created from it. Of course, not all properties will be copied one-to-one. The message’s Index, CreationTime or MessageOwner will be initialized with different values.