Skip to content

Commit 180f220

Browse files
authored
Merge pull request #112 from Skoetting/master
Added Pipeline Support to multiple Functions
2 parents ee0d878 + f901e9c commit 180f220

12 files changed

+46
-28
lines changed

src/public/Copy-ADSIGroupMembership.ps1

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ function Copy-ADSIGroupMembership{
5252
param(
5353
[Parameter(Mandatory = $true,
5454
Position = 0,
55-
ParameterSetName = "Identity")]
55+
ParameterSetName = "Identity",
56+
ValueFromPipeline = $true)]
5657
[System.string]$SourceIdentity,
5758

5859
[Parameter(Mandatory = $true,
@@ -82,9 +83,16 @@ function Copy-ADSIGroupMembership{
8283
Write-Verbose "[$FunctionName] Found DomainName Parameter"
8384
$ContextSplatting.DomainName = $DomainName
8485
}
86+
}
87+
88+
process{
8589

8690
#Get SourceIdentity Type
87-
$SourceObject = Get-ADSIObject -Identity $SourceIdentity @ContextSplatting
91+
if($SourceIdentity.GetType().FullName -eq 'System.String'){
92+
$SourceObject = Get-ADSIObject -Identity $SourceIdentity @ContextSplatting
93+
} else {
94+
$SourceObject = Get-ADSIObject -Identity $SourceIdentity.DistinguishedName @ContextSplatting
95+
}
8896
$DestinationObject = Get-ADSIObject -Identity $DestinationIdentity @ContextSplatting
8997

9098
switch -Wildcard ($SourceObject.objectclass){
@@ -98,9 +106,7 @@ function Copy-ADSIGroupMembership{
98106
"*computer" {$DestinationType = "Computer"}
99107
"*user" {$DestinationType = "User"}
100108
}
101-
}
102109

103-
process{
104110
#GetSourceGroups
105111
If($SourceType -eq "User"){
106112
$SourceGroups = (Get-ADSIUser -Identity $SourceIdentity @ContextSplatting).GetGroups()

src/public/Move-ADSIComputer.ps1

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ function Move-ADSIComputer
4141
https://msdn.microsoft.com/en-us/library/system.directoryservices.accountmanagement.computerprincipal(v=vs.110).aspx
4242
#>
4343
[CmdletBinding()]
44-
param ([Parameter(Mandatory = $true)]
45-
[string]$Identity,
44+
param ([Parameter(Mandatory = $true, ValueFromPipeline = $true)]
45+
$Identity,
4646

4747
[Alias("RunAs")]
4848
[System.Management.Automation.PSCredential]
@@ -76,7 +76,11 @@ function Move-ADSIComputer
7676
{
7777
try
7878
{
79-
$Computer = [System.DirectoryServices.AccountManagement.ComputerPrincipal]::FindByIdentity($Context, $Identity)
79+
if($Identity.GetType().FullName -eq 'System.String'){
80+
$Computer = [System.DirectoryServices.AccountManagement.ComputerPrincipal]::FindByIdentity($Context, $Identity)
81+
} else {
82+
$Computer = $Identity
83+
}
8084

8185
# Retrieve DirectoryEntry
8286
#$Computer.GetUnderlyingObject()

src/public/Move-ADSIGroup.ps1

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ function Move-ADSIGroup
4646
[OutputType('System.DirectoryServices.AccountManagement.GroupPrincipal')]
4747
param
4848
(
49-
[Parameter(Mandatory = $true)]
50-
[string]$Identity,
49+
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
50+
$Identity,
5151

5252
[Alias("RunAs")]
5353
[System.Management.Automation.PSCredential]
@@ -82,7 +82,11 @@ function Move-ADSIGroup
8282
{
8383
try
8484
{
85-
$Group = [System.DirectoryServices.AccountManagement.GroupPrincipal]::FindByIdentity($Context, $Identity)
85+
if($Identity.GetType().FullName -eq 'System.String'){
86+
$Group = [System.DirectoryServices.AccountManagement.GroupPrincipal]::FindByIdentity($Context, $Identity)
87+
} else {
88+
$Group = $Identity
89+
}
8690

8791
# Create DirectoryEntry object
8892
$NewDirectoryEntry = New-Object -TypeName System.DirectoryServices.DirectoryEntry -ArgumentList "LDAP://$Destination"

src/public/Move-ADSIUser.ps1

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ function Move-ADSIUser
4949
[OutputType('System.DirectoryServices.AccountManagement.UserPrincipal')]
5050
param
5151
(
52-
[Parameter(Mandatory = $true)]
53-
[string]$Identity,
52+
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
53+
$Identity,
5454

5555
[Alias("RunAs")]
5656
[System.Management.Automation.PSCredential]
@@ -84,7 +84,11 @@ function Move-ADSIUser
8484
{
8585
if ($Identity)
8686
{
87-
$user = [System.DirectoryServices.AccountManagement.UserPrincipal]::FindByIdentity($Context, $Identity)
87+
if($Identity.GetType().FullName -eq 'System.String'){
88+
$user = [System.DirectoryServices.AccountManagement.UserPrincipal]::FindByIdentity($Context, $Identity)
89+
} else {
90+
$user = $Identity
91+
}
8892

8993
# Retrieve DirectoryEntry
9094
#$User.GetUnderlyingObject()

src/public/Reset-ADSIUserPasswordAge.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ function Reset-ADSIUserPasswordAge
2626
[CmdletBinding(SupportsShouldProcess = $true)]
2727
param
2828
(
29-
[Parameter(Mandatory = $true)]
30-
[string]$Identity,
29+
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
30+
$Identity,
3131

3232
[Alias("RunAs")]
3333
[System.Management.Automation.PSCredential]

src/public/Set-ADSIComputer.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ function Set-ADSIComputer
4545
#>
4646
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'High', DefaultParameterSetName = 'Default')]
4747
param (
48-
[Parameter(Mandatory = $true)]
49-
[String]$Identity,
48+
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
49+
$Identity,
5050

5151
[Parameter(Mandatory = $false)]
5252
[string]$Description,

src/public/Set-ADSIGroup.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ function Set-ADSIGroup
3737
#>
3838
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'High', DefaultParameterSetName = 'Default')]
3939
param (
40-
[Parameter(Mandatory = $true)]
41-
[String]$Identity,
40+
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
41+
$Identity,
4242

4343
[Parameter(Mandatory = $false)]
4444
[string]$Description,

src/public/Set-ADSIUser.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ function Set-ADSIUser
8181
#>
8282
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'High', DefaultParameterSetName = 'Default')]
8383
param (
84-
[Parameter(Mandatory = $true)]
85-
[String]$Identity,
84+
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
85+
$Identity,
8686

8787
[Parameter(Mandatory = $false)]
8888
[string]$Country,

src/public/Set-ADSIUserPassword.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#>
3939
[CmdletBinding(SupportsShouldProcess = $true)]
4040
param (
41-
[parameter(Mandatory = $true)]
41+
[parameter(Mandatory = $true, ValueFromPipeline = $true)]
4242
$Identity,
4343

4444
[parameter(Mandatory = $true)]

src/public/Test-ADSIUserIsLockedOut.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ function Test-ADSIUserIsLockedOut
2727
[OutputType('System.Boolean')]
2828
param
2929
(
30-
[Parameter(Mandatory = $true)]
31-
[string]$Identity,
30+
[Parameter(Mandatory = $true,ValueFromPipeline = $true)]
31+
$Identity,
3232

3333
[Alias("RunAs")]
3434
[System.Management.Automation.PSCredential]

0 commit comments

Comments
 (0)