На двух разных компьютерах, подключенных к одному домену Active Directory Windows 2008 R2, рабочей станции Windows 7 и серверу Windows 2008 R2, я получаю следующую ошибку при запуске сценария PowerShell, написанного Microsoft Field Engineer I загружено из галереи Microsoft TechNet :
PS C: \ Users \ User1 \ Desktop>. \ Find-возможныйMissingSPN.ps1
Get-ADObject: Невозможно найти параметр, который соответствует имени параметра «PipelineVariable».
В C: \ Users \ User1 \ Desktop \ Find-возможныйMissingSPN.ps1: 37 char: 114
+ Get-ADObject -LDAPFilter $ filter -SearchBase $ DN -SearchScope Subtree -Proper
Связывает $ propertylist -PipelineVariable <<<< учетная запись | ForEach-Object {
<BR> + CategoryInfo: InvalidArgument: (:) [Get-ADObject], ParameterBi
ndingException
+ FullyQualifiedErrorId: NamedParameterNotFound, Microsoft.ActiveDirectory
.Management.Commands.GetADObject
Различные поиски в Google не дали ответа. Кто-нибудь знает, как решить эту проблему? Вот фактический код:
#.Synopsis
# To find possibly missing SPN registrations due to manual mistakes.
[CmdletBinding()]
Param
(
# start the search at this DN. Default is to search all of the domain.
[string]$DN = (Get-ADDomain).DistinguishedName
)
#
# define the SPN service classes to look for. Other types are mostly automated and should be OK.
#
$servicesclasses2check = @("host", "cifs", "nfs", "http", "mssql")
#
# get computers and users with a nonzero SPN within the given DN.
#
$filter = '(&(servicePrincipalname=*)(|(objectcategory=computer)(objectcategory=person)))'
$propertylist = @("servicePrincipalname", "samaccountname")
Get-ADObject -LDAPFilter $filter -SearchBase $DN -SearchScope Subtree -Properties $propertylist -PipelineVariable account | ForEach-Object {
#
# Create list of interesting SPNs for each account. Strong assumption for all code: SPN is syntactically correct.
#
$spnlist = $account.servicePrincipalName | Where-Object {
($serviceclass, $hostname, $service) = $_ -split '/'
($servicesclasses2check -contains $serviceclass) -and -not $service
}
#
# Look for cases where there is no pair of (host, host.domain) SPNs.
#
foreach ($spn in $spnlist)
{
($serviceclass, $hostname, $service) = $spn -split '/'
if ($service) { $service = "/$service" }
($fullname, $port) = $hostname -split ':'
if ($port) { $port = ":$port" }
($shortname, $domain) = $fullname -split '[.]'
#
# define the regexp matching the missing SPN and go look for it
#
if ($domain) {
$needsSPN = "${serviceclass}/${shortname}${port}${service}`$"
$needsSPNtxt = "${serviceclass}/${shortname}${port}${service}"
} else {
$needsSPN = "$serviceclass/${shortname}[.][a-zA-Z0-9-]+.*${port}${service}`$"
$needsSPNtxt = "$serviceclass/${shortname}.<domain>${port}${service}"
}
#
# search the array of SPNs to see if the _other_ SPN is there. If not, we have problem case.
#
if (-not ($spnlist -match $needsSPN))
{
[PSCustomobject] @{
samaccountname = $account.samaccountname
presentSPN = $spn
missingSPN = $needsSPNtxt
}
}
}
}