我在使用此代码在TS环境中工作时遇到了很多麻烦。
在Windows环境中,它运行良好。您可以通过谷歌搜索此代码找到任何变化,在Windows中运行正常。但是,在任务序列中,这些变体只会产生不同的错误消息,说明计算机无法移动的原因。
当我们进行psbase.MoveTo()
方法调用时,我觉得发生了一些事情。到目前为止,它可以打印出看起来像合理对象的东西。换句话说,它们不是零或其他东西。
然后$logFile = "MoveComputerLog.txt"
# Domain Credentials
$account = "domain\osdaccount"
$password = "thepassword"
function logMessage {
param ([string]$logstring)
Write-Host $logstring
Add-content $logFile -value $logstring
}
$computerName = "COMPUTERNAME"
logMessage "computerName: $computerName"
$root = "LDAP://sweet.domain.com"
$domain = New-Object System.DirectoryServices.DirectoryEntry($root, $account, $password)
$search = New-Object System.DirectoryServices.DirectorySearcher($domain)
$search.filter = "(&(objectClass=computer)(name=$computerName))"
$result = $search.findall()
$computerDN = $result.Properties.Item("DistinguishedName")
logMessage "DN: $computerDn"
$computer = New-Object System.DirectoryServices.DirectoryEntry("LDAP://$computerDN", $account, $password)
logMessage "Computer: $computer"
$destination = "LDAP://ou=here,ou=goes,ou=it,dc=sweet,dc=domain,dc=com"
$ou = New-Object System.DirectoryServices.DirectoryEntry($destination, $account, $password)
try {
# "The specified domain couldn't be connected or doesn't exist."
$computer.psbase.MoveTo($ou.Path)
} catch {
Write-Host "Encountered error while moving $computerName"
logMessage $error[0]
}
说不。
示例代码。
TextMesh totaldigit = new TextMesh();
void OnMouseUp()
{
PlayerCode += gameObject.name;
totalDigits += 1;
}
答案 0 :(得分:0)
这是定义,ADSI很重要:
PS C:\> $computer.psbase.MoveTo
OverloadDefinitions
-------------------
void MoveTo(adsi newParent)
void MoveTo(adsi newParent, string newName)
你可以试试这个,在$ result = $ search.findall()之后运行:
$computer = [ADSI]$result.path
$computer.psbase.Moveto( [ADSI]LDAP://ou=here,ou=goes,ou=it,dc=sweet,dc=domain,dc=com )