我收到错误,我不明白为什么?我用Google搜索并尽可能多地查看,但仍然没有明确的答案。这就是我快速的目标。
Checking domain DC=corp,DC=local
Ldap Error(0x1 -- Operations Error): ldap_get_next_page_s
+ CategoryInfo : NotSpecified: (Ldap Error(0x1 ...get_next_page_s:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
+ PSComputerName : computer01.corp.local
Error occured when searching for existing SPN: 0x00000001
Checking domain DC=corp,DC=local
Ldap Error(0x1 -- Operations Error): ldap_get_next_page_s
+ CategoryInfo : NotSpecified: (Ldap Error(0x1 ...get_next_page_s:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
+ PSComputerName : computer01.corp.local
Error occured when searching for existing SPN: 0x00000001
这是我正在运行的命令
$comp = "computer01.corp.local"
Invoke-Command -ComputerName $comp -ScriptBlock {
Invoke-Expression "SETSPN -S MSSQLSvc/$comp:1433 CORP\user.name"
Invoke-Expression "SETSPN -S MSSQLSvc/$comp CORP\user.name"
}
答案 0 :(得分:0)
远程会话中不存在变量$comp
,即$null
语句中的变量-ScriptBlock{..}
。试试这个:
$comp = "computer01.corp.local"
Invoke-Command -ComputerName $comp -ScriptBlock {
param($comp)
Invoke-Expression "SETSPN -S MSSQLSvc/$comp:1433 CORP\user.name"
Invoke-Expression "SETSPN -S MSSQLSvc/$comp CORP\user.name"
} -ArgumentList $comp
您可以在Write-Host "Working on computer:$comp"
下方添加param($comp)
,以验证您是否正确传递了变量$comp
。