I’m trying to tidy up a script for production and I’d like feeding if the following is over complicating the use of splatting? The original example came from Mike Robbins – http://mikefrobbins.com/2013/05/23/2013-powershell-scripting-games-advanced-event-4-auditors-love-greenbar-paper/
$LDAPGroupFilter = "(&(objectcategory=group)(objectclass=group)(mailNickname=*)(!mail=*@internal.com)(!cn=zzz*)(!cn=l-*)(!cn=g-*))"
$UserParameters = @{
Filter = $LDAPGroupFilter
Properties = 'GivenName',
'surname',
'cn',
'mail',
'proxyAddresses'
ErrorAction = 'Stop'
ErrorVariable = 'ADIssueGroup'
}
$Group = Get-ADGroup @Params
$Params.Property = $Params.Properties
$Params.Remove("Properties")
$Params.Remove("Filter")
$Group | Select-Object @Params
Paul