From 053623af04085a0eaf87591ff6d1286920c0b625 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois-Xavier=20Cat?= Date: Sat, 6 Oct 2018 19:08:38 -0700 Subject: [PATCH] Add some missing explicit parameters --- AdsiPS/Public/Get-ADSIComputer.ps1 | 4 +- AdsiPS/Public/Get-ADSIComputerSite.ps1 | 2 +- AdsiPS/Public/Get-ADSIDomain.ps1 | 2 +- AdsiPS/Public/Get-ADSIDomainMode.ps1 | 2 +- .../Get-ADSIDomainTrustRelationship.ps1 | 2 +- AdsiPS/Public/Get-ADSIForest.ps1 | 2 +- AdsiPS/Public/Get-ADSIForestDomain.ps1 | 2 +- AdsiPS/Public/Get-ADSIForestMode.ps1 | 2 +- .../Get-ADSIForestTrustRelationship.ps1 | 2 +- AdsiPS/Public/Get-ADSIFsmo.ps1 | 2 +- AdsiPS/Public/Get-ADSIGlobalCatalog.ps1 | 2 +- AdsiPS/Public/Get-ADSIGroup.ps1 | 12 +++--- AdsiPS/Public/Get-ADSIGroupMember.ps1 | 2 +- AdsiPS/Public/Get-ADSIPrintQueue.ps1 | 2 +- AdsiPS/Public/Get-ADSIReplicaDomainInfo.ps1 | 2 +- AdsiPS/Public/Get-ADSIReplicaInfo.ps1 | 4 +- AdsiPS/Public/Get-ADSISchema.ps1 | 4 +- AdsiPS/Public/Get-ADSITokenGroup.ps1 | 2 +- AdsiPS/Public/Get-ADSIUser.ps1 | 14 +++---- AdsiPS/Public/New-ADSIUser.ps1 | 2 +- AdsiPS/Public/Set-ADSIUserPassword.ps1 | 2 +- AdsiPS/Public/Test-ADSICredential.ps1 | 2 +- Archives/AdsiPs.psm1 | 42 +++++++++---------- Archives/Get-ADSIDomainDomainControllers.ps1 | 2 +- Archives/Get-ADSISiteConnection.ps1 | 2 +- Archives/Get-ADSISitesInfo.ps1 | 2 +- Archives/Remove-ADSIGroupMember.ps1 | 4 +- Archives/install.ps1 | 4 +- Tests/ADSIPs.Integration.Tests.ps1 | 2 +- WorkInProgress/GetUnderlyingSearcher.ps1 | 6 +-- WorkInProgress/Search-ADSIUser.ps1 | 2 +- 31 files changed, 69 insertions(+), 69 deletions(-) diff --git a/AdsiPS/Public/Get-ADSIComputer.ps1 b/AdsiPS/Public/Get-ADSIComputer.ps1 index 839d149..36b4d26 100644 --- a/AdsiPS/Public/Get-ADSIComputer.ps1 +++ b/AdsiPS/Public/Get-ADSIComputer.ps1 @@ -45,7 +45,7 @@ function Get-ADSIComputer .EXAMPLE $Comp = Get-ADSIComputer -Identity 'SERVER01' - $Comp.GetUnderlyingObject()| select-object * + $Comp.GetUnderlyingObject()| Select-Object -Property * Help you find all the extra properties @@ -91,7 +91,7 @@ function Get-ADSIComputer } ELSE{ $ComputerPrincipal = New-object -TypeName System.DirectoryServices.AccountManagement.ComputerPrincipal -ArgumentList $Context - $Searcher = new-object System.DirectoryServices.AccountManagement.PrincipalSearcher + $Searcher = new-object -TypeName System.DirectoryServices.AccountManagement.PrincipalSearcher $Searcher.QueryFilter = $ComputerPrincipal $Searcher.FindAll() diff --git a/AdsiPS/Public/Get-ADSIComputerSite.ps1 b/AdsiPS/Public/Get-ADSIComputerSite.ps1 index 8ffb8e0..bbd2c0f 100644 --- a/AdsiPS/Public/Get-ADSIComputerSite.ps1 +++ b/AdsiPS/Public/Get-ADSIComputerSite.ps1 @@ -85,7 +85,7 @@ public static class NetApi32 { SiteName = [NetApi32]::DsGetSiteName($Computer) } - New-Object -Type PSObject -property $Properties + New-Object -TypeName PSObject -property $Properties } CATCH { diff --git a/AdsiPS/Public/Get-ADSIDomain.ps1 b/AdsiPS/Public/Get-ADSIDomain.ps1 index 309d2f0..4402d77 100644 --- a/AdsiPS/Public/Get-ADSIDomain.ps1 +++ b/AdsiPS/Public/Get-ADSIDomain.ps1 @@ -56,7 +56,7 @@ { IF ($PSBoundParameters['Credential'] -or $PSBoundParameters['DomainName']) { - Write-Verbose '[PROCESS] Credential or DomainName specified' + Write-Verbose -Message '[PROCESS] Credential or DomainName specified' $Splatting = @{ } IF ($PSBoundParameters['Credential']) { $Splatting.Credential = $Credential } IF ($PSBoundParameters['DomainName']) { $Splatting.DomainName = $DomainName } diff --git a/AdsiPS/Public/Get-ADSIDomainMode.ps1 b/AdsiPS/Public/Get-ADSIDomainMode.ps1 index 537206c..a30f59f 100644 --- a/AdsiPS/Public/Get-ADSIDomainMode.ps1 +++ b/AdsiPS/Public/Get-ADSIDomainMode.ps1 @@ -43,7 +43,7 @@ { IF ($PSBoundParameters['Credential'] -or $PSBoundParameters['DomainName']) { - Write-Verbose '[PROCESS] Credential or DomainName specified' + Write-Verbose -Message '[PROCESS] Credential or DomainName specified' $Splatting = @{ } IF ($PSBoundParameters['Credential']) { $Splatting.Credential = $Credential } IF ($PSBoundParameters['DomainName']) { $Splatting.DomainName = $DomainName } diff --git a/AdsiPS/Public/Get-ADSIDomainTrustRelationship.ps1 b/AdsiPS/Public/Get-ADSIDomainTrustRelationship.ps1 index 8873ece..1effa70 100644 --- a/AdsiPS/Public/Get-ADSIDomainTrustRelationship.ps1 +++ b/AdsiPS/Public/Get-ADSIDomainTrustRelationship.ps1 @@ -59,7 +59,7 @@ { IF ($PSBoundParameters['Credential'] -or $PSBoundParameters['DomainName']) { - Write-Verbose '[PROCESS] Credential or FirstName specified' + Write-Verbose -Message '[PROCESS] Credential or FirstName specified' $Splatting = @{ } IF ($PSBoundParameters['Credential']) { $Splatting.Credential = $Credential } IF ($PSBoundParameters['DomainName']) { $Splatting.DomainName = $DomainName } diff --git a/AdsiPS/Public/Get-ADSIForest.ps1 b/AdsiPS/Public/Get-ADSIForest.ps1 index c566138..ae1c008 100644 --- a/AdsiPS/Public/Get-ADSIForest.ps1 +++ b/AdsiPS/Public/Get-ADSIForest.ps1 @@ -55,7 +55,7 @@ { IF ($PSBoundParameters['Credential'] -or $PSBoundParameters['ForestName']) { - Write-Verbose "[PROCESS] Credential or FirstName specified" + Write-Verbose -Message "[PROCESS] Credential or FirstName specified" $Splatting = @{ } IF ($PSBoundParameters['Credential']) { $Splatting.Credential = $Credential } IF ($PSBoundParameters['ForestName']) { $Splatting.ForestName = $ForestName } diff --git a/AdsiPS/Public/Get-ADSIForestDomain.ps1 b/AdsiPS/Public/Get-ADSIForestDomain.ps1 index 448570b..58683d5 100644 --- a/AdsiPS/Public/Get-ADSIForestDomain.ps1 +++ b/AdsiPS/Public/Get-ADSIForestDomain.ps1 @@ -49,7 +49,7 @@ { IF ($PSBoundParameters['Credential'] -or $PSBoundParameters['ForestName']) { - Write-Verbose '[PROCESS] Credential or FirstName specified' + Write-Verbose -Message '[PROCESS] Credential or FirstName specified' $Splatting = @{ } IF ($PSBoundParameters['Credential']) { $Splatting.Credential = $Credential } IF ($PSBoundParameters['ForestName']) { $Splatting.ForestName = $ForestName } diff --git a/AdsiPS/Public/Get-ADSIForestMode.ps1 b/AdsiPS/Public/Get-ADSIForestMode.ps1 index cba890f..631571e 100644 --- a/AdsiPS/Public/Get-ADSIForestMode.ps1 +++ b/AdsiPS/Public/Get-ADSIForestMode.ps1 @@ -56,7 +56,7 @@ { IF ($PSBoundParameters['Credential'] -or $PSBoundParameters['ForestName']) { - Write-Verbose '[PROCESS] Credential or FirstName specified' + Write-Verbose -Message '[PROCESS] Credential or FirstName specified' $Splatting = @{ } IF ($PSBoundParameters['Credential']) { $Splatting.Credential = $Credential } IF ($PSBoundParameters['ForestName']) { $Splatting.ForestName = $ForestName } diff --git a/AdsiPS/Public/Get-ADSIForestTrustRelationship.ps1 b/AdsiPS/Public/Get-ADSIForestTrustRelationship.ps1 index 04d279e..9444879 100644 --- a/AdsiPS/Public/Get-ADSIForestTrustRelationship.ps1 +++ b/AdsiPS/Public/Get-ADSIForestTrustRelationship.ps1 @@ -57,7 +57,7 @@ { TRY { - Write-Verbose '[Get-ADSIForestTrustRelationship][PROCESS] Credential or FirstName specified' + Write-Verbose -Message '[Get-ADSIForestTrustRelationship][PROCESS] Credential or FirstName specified' (Get-ADSIForest @PSBoundParameters).GetAllTrustRelationships() } CATCH diff --git a/AdsiPS/Public/Get-ADSIFsmo.ps1 b/AdsiPS/Public/Get-ADSIFsmo.ps1 index e246289..2970a1f 100644 --- a/AdsiPS/Public/Get-ADSIFsmo.ps1 +++ b/AdsiPS/Public/Get-ADSIFsmo.ps1 @@ -101,7 +101,7 @@ PdcRoleOwner = $Domain.PdcRoleOwner } - New-Object -Type PSObject -property $Properties + New-Object -TypeName PSObject -property $Properties } CATCH diff --git a/AdsiPS/Public/Get-ADSIGlobalCatalog.ps1 b/AdsiPS/Public/Get-ADSIGlobalCatalog.ps1 index 1f3731d..e00c013 100644 --- a/AdsiPS/Public/Get-ADSIGlobalCatalog.ps1 +++ b/AdsiPS/Public/Get-ADSIGlobalCatalog.ps1 @@ -46,7 +46,7 @@ { TRY { - Write-Verbose '[Get-ADSIGlobalCatalog][PROCESS] Credential or FirstName specified' + Write-Verbose -Message '[Get-ADSIGlobalCatalog][PROCESS] Credential or FirstName specified' (Get-ADSIForest @PSBoundParameters).GlobalCatalogs } CATCH diff --git a/AdsiPS/Public/Get-ADSIGroup.ps1 b/AdsiPS/Public/Get-ADSIGroup.ps1 index 2877402..08a5904 100644 --- a/AdsiPS/Public/Get-ADSIGroup.ps1 +++ b/AdsiPS/Public/Get-ADSIGroup.ps1 @@ -75,7 +75,7 @@ function Get-ADSIGroup .EXAMPLE $Comp = Get-ADSIGroup -Identity 'Finance' - $Comp.GetUnderlyingObject()| select-object * + $Comp.GetUnderlyingObject()| Select-Object -Property * Help you find all the extra properties of the Finance group object @@ -161,12 +161,12 @@ function Get-ADSIGroup { IF ($Identity) { - Write-Verbose "Identity" + Write-Verbose -Message "Identity" [System.DirectoryServices.AccountManagement.GroupPrincipal]::FindByIdentity($Context, $Identity) } ELSEIF ($PSBoundParameters['LDAPFilter']) { - Write-Verbose "LDAPFilter" + Write-Verbose -Message "LDAPFilter" # Directory Entry object $DirectoryEntryParams = $ContextSplatting @@ -179,17 +179,17 @@ function Get-ADSIGroup $DirectorySearcher.Filter = "(&(objectCategory=group)$LDAPFilter)" - $DirectorySearcher.FindAll() | ForEach-Object { + $DirectorySearcher.FindAll() | Foreach-Object -Process { [System.DirectoryServices.AccountManagement.GroupPrincipal]::FindByIdentity($Context, ($_.path -replace 'LDAP://')) } } ELSE { - Write-Verbose "Other Filters" + Write-Verbose -Message "Other Filters" $GroupPrincipal = New-object -TypeName System.DirectoryServices.AccountManagement.GroupPrincipal -ArgumentList $Context #$GroupPrincipal.Name = $Identity - $searcher = new-object System.DirectoryServices.AccountManagement.PrincipalSearcher + $searcher = new-object -TypeName System.DirectoryServices.AccountManagement.PrincipalSearcher $searcher.QueryFilter = $GroupPrincipal if ($PSBoundParameters['IsSecurityGroup']) { $searcher.QueryFilter.IsSecurityGroup = $IsSecurityGroup} if ($PSBoundParameters['GroupScope']) { $searcher.QueryFilter.GroupScope = $GroupScope } diff --git a/AdsiPS/Public/Get-ADSIGroupMember.ps1 b/AdsiPS/Public/Get-ADSIGroupMember.ps1 index 96e2db2..baec539 100644 --- a/AdsiPS/Public/Get-ADSIGroupMember.ps1 +++ b/AdsiPS/Public/Get-ADSIGroupMember.ps1 @@ -61,7 +61,7 @@ function Get-ADSIGroupMember .EXAMPLE $Comp = Get-ADSIGroupMember -Identity 'SERVER01' - $Comp.GetUnderlyingObject()| select-object * + $Comp.GetUnderlyingObject()| Select-Object -Property * Help you find all the extra properties diff --git a/AdsiPS/Public/Get-ADSIPrintQueue.ps1 b/AdsiPS/Public/Get-ADSIPrintQueue.ps1 index bd98e14..b2c9f35 100644 --- a/AdsiPS/Public/Get-ADSIPrintQueue.ps1 +++ b/AdsiPS/Public/Get-ADSIPrintQueue.ps1 @@ -168,7 +168,7 @@ IF (-not$PSBoundParameters['NoResultLimit']) { $Search.SizeLimit = $SizeLimit - Write-warning "Result is limited to $SizeLimit entries, specify a specific number on the parameter SizeLimit or use -NoResultLimit switch to remove the limit" + Write-Warning -Message "Result is limited to $SizeLimit entries, specify a specific number on the parameter SizeLimit or use -NoResultLimit switch to remove the limit" } ELSE { diff --git a/AdsiPS/Public/Get-ADSIReplicaDomainInfo.ps1 b/AdsiPS/Public/Get-ADSIReplicaDomainInfo.ps1 index ca1000d..5aa582f 100644 --- a/AdsiPS/Public/Get-ADSIReplicaDomainInfo.ps1 +++ b/AdsiPS/Public/Get-ADSIReplicaDomainInfo.ps1 @@ -74,7 +74,7 @@ $dc.domain if ($Recurse.IsPresent) { - $dc.domain.children | ForEach-Object { $_ } + $dc.domain.children | Foreach-Object -Process { $_ } } } diff --git a/AdsiPS/Public/Get-ADSIReplicaInfo.ps1 b/AdsiPS/Public/Get-ADSIReplicaInfo.ps1 index 569332f..d83aec0 100644 --- a/AdsiPS/Public/Get-ADSIReplicaInfo.ps1 +++ b/AdsiPS/Public/Get-ADSIReplicaInfo.ps1 @@ -189,7 +189,7 @@ } $domainDN = "" $obj = $domain.Replace(',', '\,').Split('/') - $obj[0].split(".") | ForEach-Object { $domainDN += ",DC=" + $_ } + $obj[0].split(".") | Foreach-Object -Process { $domainDN += ",DC=" + $_ } $domainDN = $domainDN.Substring(1) if ($Cursors.IsPresent) @@ -204,7 +204,7 @@ { Write-Verbose -Message "Replication cursors for partition $partition on $($dc.Name)" - $dc.GetReplicationCursors($partition) | ForEach-Object { $_ } + $dc.GetReplicationCursors($partition) | Foreach-Object -Process { $_ } } } diff --git a/AdsiPS/Public/Get-ADSISchema.ps1 b/AdsiPS/Public/Get-ADSISchema.ps1 index 021e093..72cc9c8 100644 --- a/AdsiPS/Public/Get-ADSISchema.ps1 +++ b/AdsiPS/Public/Get-ADSISchema.ps1 @@ -68,7 +68,7 @@ { IF ($PSBoundParameters['Credential'] -or $PSBoundParameters['ForestName']) { - Write-Verbose '[PROCESS] Credential or ForestName specified' + Write-Verbose -Message '[PROCESS] Credential or ForestName specified' $Splatting = @{ } IF ($PSBoundParameters['Credential']) { $Splatting.Credential = $Credential } IF ($PSBoundParameters['ForestName']) { $Splatting.ForestName = $ForestName} @@ -94,7 +94,7 @@ } IF ($PSBoundParameters['FindClassName']) { - $schema.FindAllClasses() | Where-Object { $_.name -match $FindClassName } | Select-Object -Property Name + $schema.FindAllClasses() | Where-Object -FilterScript { $_.name -match $FindClassName } | Select-Object -Property Name } ELSE diff --git a/AdsiPS/Public/Get-ADSITokenGroup.ps1 b/AdsiPS/Public/Get-ADSITokenGroup.ps1 index 2678827..21fab89 100644 --- a/AdsiPS/Public/Get-ADSITokenGroup.ps1 +++ b/AdsiPS/Public/Get-ADSITokenGroup.ps1 @@ -91,7 +91,7 @@ FOREACH ($Token in $($AccountGetDirectory.Get("tokenGroups"))) { # Create SecurityIdentifier to translate into group name - $Principal = New-Object System.Security.Principal.SecurityIdentifier($token, 0) + $Principal = New-Object -TypeName System.Security.Principal.SecurityIdentifier($token, 0) # Prepare Output $Properties = @{ diff --git a/AdsiPS/Public/Get-ADSIUser.ps1 b/AdsiPS/Public/Get-ADSIUser.ps1 index 1edc64e..f5a2f64 100644 --- a/AdsiPS/Public/Get-ADSIUser.ps1 +++ b/AdsiPS/Public/Get-ADSIUser.ps1 @@ -75,7 +75,7 @@ function Get-ADSIUser .EXAMPLE $user = Get-ADSIUser -Identity 'testaccount' - $user.GetUnderlyingObject()| select-object * + $user.GetUnderlyingObject()| Select-Object -Property * Help you find all the extra properties and methods available @@ -128,7 +128,7 @@ function Get-ADSIUser { IF ($Identity) { - Write-Verbose "Identity" + Write-Verbose -Message "Identity" [System.DirectoryServices.AccountManagement.UserPrincipal]::FindByIdentity($Context, $Identity) } @@ -147,26 +147,26 @@ function Get-ADSIUser $DirectorySearcher.Filter = "(&(objectCategory=user)$LDAPFilter)" #$DirectorySearcher.PropertiesToLoad.AddRange("'Enabled','SamAccountName','DistinguishedName','Sid','DistinguishedName'") - if(-not$PSBoundParameters['NoResultLimit']){Write-warning "Result is limited to 1000 entries, specify a specific number on the parameter SizeLimit or 0 to remove the limit"} + if(-not$PSBoundParameters['NoResultLimit']){Write-Warning -Message "Result is limited to 1000 entries, specify a specific number on the parameter SizeLimit or 0 to remove the limit"} else{ # SizeLimit is useless, even if there is a$Searcher.GetUnderlyingSearcher().sizelimit=$SizeLimit # the server limit is kept $DirectorySearcher.PageSize = 10000 } - $DirectorySearcher.FindAll() | ForEach-Object { + $DirectorySearcher.FindAll() | Foreach-Object -Process { [System.DirectoryServices.AccountManagement.UserPrincipal]::FindByIdentity($Context, $_.Properties["distinguishedname"]) }# Return UserPrincipale object } ELSE { - Write-Verbose "Searcher" + Write-Verbose -Message "Searcher" $UserPrincipal = New-object -TypeName System.DirectoryServices.AccountManagement.UserPrincipal -ArgumentList $Context - $Searcher = new-object System.DirectoryServices.AccountManagement.PrincipalSearcher + $Searcher = New-Object -TypeName System.DirectoryServices.AccountManagement.PrincipalSearcher $Searcher.QueryFilter = $UserPrincipal - if(-not$PSBoundParameters['NoResultLimit']){Write-warning "Result is limited to 1000 entries, specify a specific number on the parameter SizeLimit or 0 to remove the limit"} + if(-not$PSBoundParameters['NoResultLimit']){Write-Warning -Message "Result is limited to 1000 entries, specify a specific number on the parameter SizeLimit or 0 to remove the limit"} else { # SizeLimit is useless, even if there is a$Searcher.GetUnderlyingSearcher().sizelimit=$SizeLimit # the server limit is kept diff --git a/AdsiPS/Public/New-ADSIUser.ps1 b/AdsiPS/Public/New-ADSIUser.ps1 index 66ecff9..0f0ddfe 100644 --- a/AdsiPS/Public/New-ADSIUser.ps1 +++ b/AdsiPS/Public/New-ADSIUser.ps1 @@ -147,7 +147,7 @@ IF ($PSBoundParameters['HomeDrive']) { $user.HomeDrive = $HomeDrive } IF ($PSBoundParameters['MiddleName']) { $user.MiddleName = $MiddleName } IF ($PSBoundParameters['VoiceTelephoneNumber']) { $user.VoiceTelephoneNumber } - IF ($PSBoundParameters['AccountPassword']){$User.SetPassword((New-Object PSCredential "user",$AccountPassword).GetNetworkCredential().Password)} + IF ($PSBoundParameters['AccountPassword']){$User.SetPassword((New-Object -TypeName PSCredential -ArgumentList "user",$AccountPassword).GetNetworkCredential().Password)} Write-Verbose -message "Create the Account in Active Directory" $User.Save($Context) diff --git a/AdsiPS/Public/Set-ADSIUserPassword.ps1 b/AdsiPS/Public/Set-ADSIUserPassword.ps1 index 3a60d5c..a862f9f 100644 --- a/AdsiPS/Public/Set-ADSIUserPassword.ps1 +++ b/AdsiPS/Public/Set-ADSIUserPassword.ps1 @@ -68,7 +68,7 @@ { if ($pscmdlet.ShouldProcess("$Identity", "Change Account Password")) { - (Get-ADSIUser -Identity $Identity @ContextSplatting).SetPassword((New-Object PSCredential "user",$AccountPassword).GetNetworkCredential().Password) + (Get-ADSIUser -Identity $Identity @ContextSplatting).SetPassword((New-Object -TypeName PSCredential -ArgumentList "user",$AccountPassword).GetNetworkCredential().Password) } } CATCH diff --git a/AdsiPS/Public/Test-ADSICredential.ps1 b/AdsiPS/Public/Test-ADSICredential.ps1 index 8637d30..2117c6c 100644 --- a/AdsiPS/Public/Test-ADSICredential.ps1 +++ b/AdsiPS/Public/Test-ADSICredential.ps1 @@ -73,7 +73,7 @@ function Test-ADSICredential TRY { Write-Verbose -Message "[Test-ADSICredential][PROCESS] Validating $AccountName Credential against $($Context.ConnectedServer)" - $Context.ValidateCredentials($AccountName, (New-Object PSCredential "user",$AccountPassword).GetNetworkCredential().Password) + $Context.ValidateCredentials($AccountName, (New-Object -TypeName PSCredential -ArgumentList "user",$AccountPassword).GetNetworkCredential().Password) } CATCH { diff --git a/Archives/AdsiPs.psm1 b/Archives/AdsiPs.psm1 index 864a03b..bdf0925 100644 --- a/Archives/AdsiPs.psm1 +++ b/Archives/AdsiPs.psm1 @@ -605,7 +605,7 @@ function New-ADSIPrincipalContext ELSE { Write-Verbose -Message "[New-ADSIPrincipalContext][PROCESS] Creating a $PrincipalContextType Principal Context WITHOUT Credential" - New-Object System.DirectoryServices.AccountManagement.PrincipalContext -ArgumentList $PrincipalContextType + New-Object -TypeName System.DirectoryServices.AccountManagement.PrincipalContext -ArgumentList $PrincipalContextType } } CATCH @@ -669,7 +669,7 @@ Function Get-ADSIDomain { IF ($PSBoundParameters['Credential'] -or $PSBoundParameters['DomainName']) { - Write-Verbose '[PROCESS] Credential or DomainName specified' + Write-Verbose -Message '[PROCESS] Credential or DomainName specified' $Splatting = @{ } IF ($PSBoundParameters['Credential']) { $Splatting.Credential = $Credential } IF ($PSBoundParameters['DomainName']) { $Splatting.DomainName = $DomainName } @@ -707,7 +707,7 @@ Function Get-ADSIDomainMode { IF ($PSBoundParameters['Credential'] -or $PSBoundParameters['DomainName']) { - Write-Verbose '[PROCESS] Credential or DomainName specified' + Write-Verbose -Message '[PROCESS] Credential or DomainName specified' $Splatting = @{ } IF ($PSBoundParameters['Credential']) { $Splatting.Credential = $Credential } IF ($PSBoundParameters['DomainName']) { $Splatting.DomainName = $DomainName } @@ -763,7 +763,7 @@ Function Get-ADSIDomainTrustRelationship { IF ($PSBoundParameters['Credential'] -or $PSBoundParameters['DomainName']) { - Write-Verbose '[PROCESS] Credential or FirstName specified' + Write-Verbose -Message '[PROCESS] Credential or FirstName specified' $Splatting = @{ } IF ($PSBoundParameters['Credential']) { $Splatting.Credential = $Credential } IF ($PSBoundParameters['DomainName']) { $Splatting.DomainName = $DomainName } @@ -926,7 +926,7 @@ Function Get-ADSIDomainDomainControllers { IF ($PSBoundParameters['Credential'] -or $PSBoundParameters['DomainName']) { - Write-Verbose '[PROCESS] Credential or FirstName specified' + Write-Verbose -Message '[PROCESS] Credential or FirstName specified' $Splatting = @{ } IF ($PSBoundParameters['Credential']) { $Splatting.Credential = $Credential } IF ($PSBoundParameters['DomainName']) { $Splatting.DomainName = $DomainName } @@ -1105,7 +1105,7 @@ Function Get-ADSIForest { IF ($PSBoundParameters['Credential'] -or $PSBoundParameters['ForestName']) { - Write-Verbose "[PROCESS] Credential or FirstName specified" + Write-Verbose -Message "[PROCESS] Credential or FirstName specified" $Splatting = @{ } IF ($PSBoundParameters['Credential']) { $Splatting.Credential = $Credential } IF ($PSBoundParameters['ForestName']) { $Splatting.ForestName = $ForestName } @@ -1143,7 +1143,7 @@ Function Get-ADSIForestMode { IF ($PSBoundParameters['Credential'] -or $PSBoundParameters['ForestName']) { - Write-Verbose '[PROCESS] Credential or FirstName specified' + Write-Verbose -Message '[PROCESS] Credential or FirstName specified' $Splatting = @{ } IF ($PSBoundParameters['Credential']) { $Splatting.Credential = $Credential } IF ($PSBoundParameters['ForestName']) { $Splatting.ForestName = $ForestName } @@ -1181,7 +1181,7 @@ Function Get-ADSIForestDomain { IF ($PSBoundParameters['Credential'] -or $PSBoundParameters['ForestName']) { - Write-Verbose '[PROCESS] Credential or FirstName specified' + Write-Verbose -Message '[PROCESS] Credential or FirstName specified' $Splatting = @{ } IF ($PSBoundParameters['Credential']) { $Splatting.Credential = $Credential } IF ($PSBoundParameters['ForestName']) { $Splatting.ForestName = $ForestName } @@ -1219,7 +1219,7 @@ Function Get-ADSIForestTrustRelationship { IF ($PSBoundParameters['Credential'] -or $PSBoundParameters['ForestName']) { - Write-Verbose '[PROCESS] Credential or FirstName specified' + Write-Verbose -Message '[PROCESS] Credential or FirstName specified' $Splatting = @{ } IF ($PSBoundParameters['Credential']) { $Splatting.Credential = $Credential } IF ($PSBoundParameters['ForestName']) { $Splatting.ForestName = $ForestName } @@ -1363,7 +1363,7 @@ Function Get-ADSIGlobalCatalogs { IF ($PSBoundParameters['Credential'] -or $PSBoundParameters['ForestName']) { - Write-Verbose '[PROCESS] Credential or FirstName specified' + Write-Verbose -Message '[PROCESS] Credential or FirstName specified' $Splatting = @{ } IF ($PSBoundParameters['Credential']) { $Splatting.Credential = $Credential } IF ($PSBoundParameters['ForestName']) { $Splatting.ForestName = $ForestName } @@ -1453,7 +1453,7 @@ function Get-ADSISchema } IF ($PSBoundParameters['FindClassName']) { - $schema.FindAllClasses() | Where-Object { $_.name -match $FindClassName } | Select-Object -Property Name + $schema.FindAllClasses() | Where-Object -FilterScript { $_.name -match $FindClassName } | Select-Object -Property Name } ELSE @@ -2110,13 +2110,13 @@ function Remove-ADSIGroupMember IF (Test-ADSIUserIsGroupMember -GroupSamAccountName $GroupSamAccountName -UserSamAccountName $UserSamAccountName) { - Write-Verbose "Removing $UserSamAccountName from $GroupSamAccountName" + Write-Verbose -Message "Removing $UserSamAccountName from $GroupSamAccountName" $GroupInfo.Remove($UserInfo.ADsPath) } ELSE { - Write-Verbose "$UserSamAccountName is not member of $GroupSamAccountName" + Write-Verbose -Message "$UserSamAccountName is not member of $GroupSamAccountName" } } @@ -2297,7 +2297,7 @@ function Get-ADSITokenGroup FOREACH ($Token in $($AccountGetDirectory.Get("tokenGroups"))) { # Create SecurityIdentifier to translate into group name - $Principal = New-Object System.Security.Principal.SecurityIdentifier($token, 0) + $Principal = New-Object -TypeName System.Security.Principal.SecurityIdentifier($token, 0) # Prepare Output $Properties = @{ @@ -2366,7 +2366,7 @@ function Test-ADSICredential { TRY { - $DomainPrincipalContext = New-Object System.DirectoryServices.AccountManagement.PrincipalContext('domain') + $DomainPrincipalContext = New-Object -TypeName System.DirectoryServices.AccountManagement.PrincipalContext('domain') Write-Verbose -Message "[Test-ADCredential][PROCESS] Validating $AccountName Credential against $($DomainPrincipalContext.ConnectedServer)" $DomainPrincipalContext.ValidateCredentials($AccountName, $Password) @@ -2823,7 +2823,7 @@ function Get-ADSIReplicaDomainInfo $dc.domain if ($Recurse.IsPresent) { - $dc.domain.children | ForEach-Object { $_ } + $dc.domain.children | Foreach-Object -Process { $_ } } } @@ -3231,7 +3231,7 @@ function Get-ADSIReplicaInfo } $domainDN = "" $obj = $domain.Replace(',', '\,').Split('/') - $obj[0].split(".") | ForEach-Object { $domainDN += ",DC=" + $_ } + $obj[0].split(".") | Foreach-Object -Process { $domainDN += ",DC=" + $_ } $domainDN = $domainDN.Substring(1) if ($Cursors.IsPresent) @@ -3246,7 +3246,7 @@ function Get-ADSIReplicaInfo { Write-Verbose -Message "Replication cursors for partition $partition on $($dc.Name)" - $dc.GetReplicationCursors($partition) | ForEach-Object { $_ } + $dc.GetReplicationCursors($partition) | Foreach-Object -Process { $_ } } } @@ -3345,7 +3345,7 @@ function Get-ADSIReplicaInfo { if ($FormatTable.IsPresent) { - $neighbor | Select-Object SourceServer, LastSyncMessage, LastAttemptedSync, LastSuccessfulSync, PartitionName | Format-Table -AutoSize + $neighbor | Select-Object -Property SourceServer, LastSyncMessage, LastAttemptedSync, LastSuccessfulSync, PartitionName | Format-Table -AutoSize } else { @@ -3684,7 +3684,7 @@ function Get-ADSISitesInfo if ($dc) { Write-Verbose -Message "Information about forest $($dc.forest.name)" - $dc.forest.sites | ForEach-Object { $_ } + $dc.forest.sites | Foreach-Object -Process { $_ } } } @@ -3888,7 +3888,7 @@ function Get-ADSISiteConnection ) $DomainName = $Domain.Name $ADEntry = [system.directoryservices.directoryentry]([ADSI]"LDAP://$DomainName") - $source = New-Object System.DirectoryServices.DirectorySearcher + $source = New-Object -TypeName System.DirectoryServices.DirectorySearcher $source.SearchRoot = "LDAP://CN=$Site,CN=Sites,CN=Configuration,$DomainName" $source.SearchScope = 'Subtree' $source.PageSize = 100000 diff --git a/Archives/Get-ADSIDomainDomainControllers.ps1 b/Archives/Get-ADSIDomainDomainControllers.ps1 index 92943be..078a3a7 100644 --- a/Archives/Get-ADSIDomainDomainControllers.ps1 +++ b/Archives/Get-ADSIDomainDomainControllers.ps1 @@ -14,7 +14,7 @@ { IF ($PSBoundParameters['Credential'] -or $PSBoundParameters['DomainName']) { - Write-Verbose '[PROCESS] Credential or FirstName specified' + Write-Verbose -Message '[PROCESS] Credential or FirstName specified' $Splatting = @{ } IF ($PSBoundParameters['Credential']) { $Splatting.Credential = $Credential } IF ($PSBoundParameters['DomainName']) { $Splatting.DomainName = $DomainName } diff --git a/Archives/Get-ADSISiteConnection.ps1 b/Archives/Get-ADSISiteConnection.ps1 index 3a8ded3..0559182 100644 --- a/Archives/Get-ADSISiteConnection.ps1 +++ b/Archives/Get-ADSISiteConnection.ps1 @@ -10,7 +10,7 @@ ) $DomainName = $Domain.Name $ADEntry = [system.directoryservices.directoryentry]([ADSI]"LDAP://$DomainName") - $source = New-Object System.DirectoryServices.DirectorySearcher + $source = New-Object -TypeName System.DirectoryServices.DirectorySearcher $source.SearchRoot = "LDAP://CN=$Site,CN=Sites,CN=Configuration,$DomainName" $source.SearchScope = 'Subtree' $source.PageSize = 100000 diff --git a/Archives/Get-ADSISitesInfo.ps1 b/Archives/Get-ADSISitesInfo.ps1 index d21d6ab..37298d2 100644 --- a/Archives/Get-ADSISitesInfo.ps1 +++ b/Archives/Get-ADSISitesInfo.ps1 @@ -76,6 +76,6 @@ if ($dc) { Write-Verbose -Message "Information about forest $($dc.forest.name)" - $dc.forest.sites | ForEach-Object { $_ } + $dc.forest.sites | Foreach-Object -Process { $_ } } } \ No newline at end of file diff --git a/Archives/Remove-ADSIGroupMember.ps1 b/Archives/Remove-ADSIGroupMember.ps1 index 4dda995..00905e4 100644 --- a/Archives/Remove-ADSIGroupMember.ps1 +++ b/Archives/Remove-ADSIGroupMember.ps1 @@ -22,12 +22,12 @@ IF (Test-ADSIUserIsGroupMember -GroupSamAccountName $GroupSamAccountName -UserSamAccountName $UserSamAccountName) { - Write-Verbose "Removing $UserSamAccountName from $GroupSamAccountName" + Write-Verbose -Message "Removing $UserSamAccountName from $GroupSamAccountName" $GroupInfo.Remove($UserInfo.ADsPath) } ELSE { - Write-Verbose "$UserSamAccountName is not member of $GroupSamAccountName" + Write-Verbose -Message "$UserSamAccountName is not member of $GroupSamAccountName" } } \ No newline at end of file diff --git a/Archives/install.ps1 b/Archives/install.ps1 index a3d6130..52c1fac 100644 --- a/Archives/install.ps1 +++ b/Archives/install.ps1 @@ -11,7 +11,7 @@ if ('' -eq $InstallDirectory) $personalModules = Join-Path -Path ([Environment]::GetFolderPath('MyDocuments')) -ChildPath WindowsPowerShell\Modules if (($env:PSModulePath -split ';') -notcontains $personalModules) { - Write-Warning "$personalModules is not in `$env:PSModulePath" + Write-Warning -Message "$personalModules is not in `$env:PSModulePath" } if (-not(Test-Path $personalModules)) { @@ -27,6 +27,6 @@ if (-not(Test-Path $InstallDirectory)) { $WebClient = New-Object -typename System.Net.WebClient $fileList | - ForEach-Object { + Foreach-Object -Process { $WebClient.DownloadFile("https://raw.github.com/LazyWinAdmin/$ModuleName/master/$_","$installDirectory\$_") } diff --git a/Tests/ADSIPs.Integration.Tests.ps1 b/Tests/ADSIPs.Integration.Tests.ps1 index 2c7477b..3551f0f 100644 --- a/Tests/ADSIPs.Integration.Tests.ps1 +++ b/Tests/ADSIPs.Integration.Tests.ps1 @@ -85,7 +85,7 @@ Describe "$ModuleName Module - HELP" -Tags "Module" { $HelpParameters.name.count -eq $ASTParameters.count | Should Be $true} # Parameters Description - $HelpParameters| ForEach-Object { + $HelpParameters| Foreach-Object -Process { It "Parameter $($_.Name) - Should contains description"{ $_.description | Should not BeNullOrEmpty } diff --git a/WorkInProgress/GetUnderlyingSearcher.ps1 b/WorkInProgress/GetUnderlyingSearcher.ps1 index 8465e55..ab1314d 100644 --- a/WorkInProgress/GetUnderlyingSearcher.ps1 +++ b/WorkInProgress/GetUnderlyingSearcher.ps1 @@ -3,7 +3,7 @@ $UserPrincipal = New-object -TypeName System.DirectoryServices.AccountManagement #$GroupPrincipal.Name = $Identity -$searcher = new-object System.DirectoryServices.AccountManagement.PrincipalSearcher +$searcher = New-Object -TypeName System.DirectoryServices.AccountManagement.PrincipalSearcher $searcher.QueryFilter = $UserPrincipal $searcher.QueryFilter.Enabled=$false $searcher.QueryFilter.SamAccountName="fx*" @@ -51,7 +51,7 @@ $UserPrincipal = New-object -TypeName System.DirectoryServices.AccountManagement #$GroupPrincipal.Name = $Identity -$searcher = new-object System.DirectoryServices.AccountManagement.PrincipalSearcher +$searcher = New-Object -TypeName System.DirectoryServices.AccountManagement.PrincipalSearcher $searcher.QueryFilter = $UserPrincipal $searcher.QueryFilter.AdvancedSearchFilter. #$searcher.GetUnderlyingSearcher().Filter = "(&(objectCategory=user)(objectClass=user)(samaccountname=fxt)(userAccountControl:1.2.840.113556.1.4.803:=2))" @@ -63,5 +63,5 @@ $searcher.FindAll()|Select-Object -Propertyname $Context = New-ADSIPrincipalContext -ContextType Domain $UserPrincipal = New-object -TypeName System.DirectoryServices.AccountManagement.UserPrincipal -ArgumentList $Context -$searcher2 = new-object system.directoryservices.directorysearcher -ArgumentList $UserPrincipal +$searcher2 = New-Object -TypeName System.directoryservices.directorysearcher -ArgumentList $UserPrincipal $searcher2.q diff --git a/WorkInProgress/Search-ADSIUser.ps1 b/WorkInProgress/Search-ADSIUser.ps1 index 81371c4..733058d 100644 --- a/WorkInProgress/Search-ADSIUser.ps1 +++ b/WorkInProgress/Search-ADSIUser.ps1 @@ -6,7 +6,7 @@ $UserPrincipal.Surname = "E*" # it will generate the filter for you -$Searcher = new-object System.DirectoryServices.AccountManagement.PrincipalSearcher +$Searcher = New-Object -TypeName System.DirectoryServices.AccountManagement.PrincipalSearcher $Searcher.QueryFilter = $UserPrincipal