Skip to content

Instantly share code, notes, and snippets.

@Jackbennett
Created June 5, 2018 12:25
Show Gist options
  • Save Jackbennett/9f9b8b6bc6a10ea22d0a1626927ead27 to your computer and use it in GitHub Desktop.
Save Jackbennett/9f9b8b6bc6a10ea22d0a1626927ead27 to your computer and use it in GitHub Desktop.
[cmdletbinding(SupportsShouldProcess=$true,DefaultParameterSetName="User")]
Param(
[Parameter(Mandatory=$true,
Position=0,
ParameterSetName="User",
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true)]
[Microsoft.ActiveDirectory.Management.ADUser[]]
[Parameter(Mandatory=$true,
Position=0,
ParameterSetName="GroupMember",
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true)]
[Microsoft.ActiveDirectory.Management.ADPrincipal[]]
$Identity,
)
$gm = get-adgroupmember...
New-CADirectory : Cannot bind argument to parameter 'Identity' because it is an empty array.
At line:1 char:7
+ $gm | New-CADirectory -SubjectName test -intake 2016 -WhatIf
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (CN=username,OU=2...org,DC=INTERNAL:PSObject) [New-CADirectory], ParameterB
indingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyArrayNotAllowed,New-CADirectory
$u = get-adgroupmember | get-aduser
$u | New-CADirectory -SubjectName test -intake 2016 -WhatIf
What if: Performing the operation "Create Directory" on target "\path\test\username".
etc...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment