我收到此PowerShell脚本的以下错误,该脚本连接到远程DC并导入AD模块以及获取本地计算机名称以根据名称将其移动到指定的OU
$remServer="DC1"
$s=new-PSSession -Computer $remServer
Invoke-Command -Session $s -script {Import-Module ActiveDirectory}
Import-PSSession -Session $s -module ActiveDirectory
$movePC = gc env:computername
if($movePC.substring(5,3) -imatch "Dbs"){
$TargetOU ='ou=DB Servers,ou=PRD,ou=Servers,dc=com,dc=company,dc=net'
Get-ADComputer $movePC | Move-ADObject -Targetpath $TargetOU}
Remove-PSSession -Session $s
Script 1.0 tmp_54y3mzbf.25i {Add-
ADCentralAccessPolicyMember, Add-ADComputerServiceAccount, Add-
ADDomainControllerPasswordReplicationPolicy, Add-...
The input object cannot be bound to any parameters for the command either
because the command does not take pipeline input or the input and its
properties do not match any of
the parameters that take pipeline input.
+ CategoryInfo : InvalidArgument: (CN=123123DBSTST0...company,DC=net:PSObject) [Move-ADObject], ParameterBindingException
+ FullyQualifiedErrorId : InputObjectNotBound,Microsoft.ActiveDirectory.Management.Commands.MoveADObject
+ PSComputerName : DC1**
答案 0 :(得分:0)
试一试:
import org.apache.log4j.*;
public class ThreadLogger {
String sThreadName;
String sLogfilePath;
RollingFileAppender rfaJob;
PatternLayout plJobLog;
public ThreadLogger(){}
public void start(String sThreadId, String sLogfilePath){
this.sThreadName = sThreadId;
this.sLogfilePath = sLogfilePath;
// Create Logfilter and LogAppender for thread based logging
ThreadLoggingFilter ThreadLogFilter = new ThreadLoggingFilter(this.sThreadName);
plJobLog = new PatternLayout("[%x - %t][%d / %p / %c] - %m%n");
this.rfaJob = new RollingFileAppender();
this.rfaJob.setLayout(plJobLog);
this.rfaJob.setFile(sLogfilePath);
this.rfaJob.setEncoding("UTF-8");
this.rfaJob.activateOptions();
this.rfaJob.setMaxBackupIndex(9);
this.rfaJob.setMaxFileSize("10MB");
this.rfaJob.setThreshold(Level.ALL);
this.rfaJob.addFilter(ThreadLogFilter);
Logger.getRootLogger().addAppender(this.rfaJob);
}
public void stop(){
Logger.getRootLogger().removeAppender(this.rfaJob);
this.rfaJob.close();
}
}