Showing posts with label PowerShell GUI. Show all posts
Showing posts with label PowerShell GUI. Show all posts

08 January 2016

Graphical User Interface for PowerShell scripts

We have two options for creating a GUI for a PowerShell script:
  • Windows Forms (WinForms)
  • Windows Presentation Foundation (WPF)
WinForms use only native Windows interface elements - limited control on how things will look like.

With WPF you have full freedom of design but it's way more complicated than WinForms.
WPF is built on DirectX - this provide hardware acceleration and also enables modern UI features like transparency, gradients and transforms.

Also WPF offers a new markup language alternative - XAML - a different means of defining UI elements. An application that is defined as WPF is able to be deployed on the desktop or hosted on a webserver.

WinForms are events driven.

07 January 2016

Convert exported FIM object to a custom PSObject

Function Convert-FimObjectToPSObject {
    Param (
        [parameter(Mandatory=$true, ValueFromPipeline = $true)]
        [Microsoft.ResourceManagement.Automation.ObjectModel.ExportObject]
        $FIMObject
    )
    Process
    {      
        $PSObject = New-Object PSObject

        foreach($Attribute in $FIMObject.ResourceManagementObject.ResourceManagementAttributes){
                if ($Attribute.Value -ne $null) { $Value = $Attribute.Value }
                elseif($Attribute.Values -ne $null)  { $Value = $Attribute.Values  }
                else  { $Value = $null }

                $PSObject | Add-Member -MemberType NoteProperty -Name $Attribute.AttributeName -Value $Value
        }
        Write-Output $PSObject
    }
}

$FIMPSObject = Convert-FimObjectToPSObject -FIMObject $FimGroup
$FIMPSObject