Hello,
I have been working on a PowerShell tool to create users in Active Directory with a GUI.
Thanks to Tobias Weltner and his ISESteroids it is now easy to work with XAML in PowerShell ISE.
For this tool I had to create couple of dropdown which will contains Sites list, Company list, Preferred Language list and Department list based on an XML config file.
Function New-ComboBoxItem {
[CmdletBinding()]
Param(
[Parameter(
Mandatory = $true
)]
[String]$ComboBoxName,
[Parameter(
Mandatory = $true
)]
[String[]]$Item,
[Object]$Window = $Window
)
foreach ($object in $Item) {
$null = $Window.$ComboBoxName.Items.Add($object)
}
}
I used??$null variable??because the item id was returned.
Here is an example of the XAML I used to create the ComboBox, without items created – yet.
<ComboBox Name=”SitesList” Grid.Column=”1″ HorizontalAlignment=”Left” Margin=”10,208,0,0″ VerticalAlignment=”Top” Width=”153″/>
The way I use the function:
New-ComboBoxItem -ComboBoxName 'SitesList' -Item ($config.Config.Companies.company).Name