Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 将结果写入文件,而不是写入Active Directory live环境_Powershell_Logging_Export To Csv - Fatal编程技术网

Powershell 将结果写入文件,而不是写入Active Directory live环境

Powershell 将结果写入文件,而不是写入Active Directory live环境,powershell,logging,export-to-csv,Powershell,Logging,Export To Csv,在生产环境中实际运行该脚本之前,我需要输出该脚本将执行的操作。有人能帮忙吗 它所做的只是更新用户对象中的属性EmployeeID。我的经理想从所有3500名员工在广告中获得的价值中得到一个信息,而不必实际写信给它。我希望这是有道理的 我的CSV文件: employeeid,Name 9089809890,ktest 脚本: $stuff = Import-Csv c:\temp\finalexport_test.txt $stuff $empid = $stuff.employeeid $u

在生产环境中实际运行该脚本之前,我需要输出该脚本将执行的操作。有人能帮忙吗

它所做的只是更新用户对象中的属性EmployeeID。我的经理想从所有3500名员工在广告中获得的价值中得到一个信息,而不必实际写信给它。我希望这是有道理的

我的CSV文件:

employeeid,Name
9089809890,ktest
脚本:

$stuff = Import-Csv c:\temp\finalexport_test.txt
$stuff

$empid = $stuff.employeeid
$userid = $stuff.name

foreach ($user in $userid) {
    Set-ADUser -Identity $user -EmployeeID $empid
    }

您可以将
Set-AdUser
cmdlet上的
-whatif
标志与转录本一起使用:

$stuff = Import-Csv c:\temp\finalexport_test.txt
$stuff

$empid = $stuff.employeeid
$userid = $stuff.name

foreach ($user in $userid) {
    Start-Transcript 'yourFile'
    Set-ADUser -Identity $user -EmployeeID $empid -whatif
    Stop-Transcript
    }