19 January 2016

Ldap filter enabled users


(&(objectCategory=organizationalPerson)(objectClass=User)(userAccountControl:1.2.840.113556.1.4.803:=2))


for disabled users:

(&(objectCategory=organizationalPerson)(objectClass=User)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))

09 January 2016

Windows buit-in checksum utility


certutil -hashfile pathToFileToCheck MD5

it can also calculate for MD2 MD4 MD5 SHA1 SHA256 SHA384 SHA512

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