我知道在unix世界中,如果编辑.profile或.cshrc文件,可以使用source~/.profile或source~/.cshrc来获取当前会话的效果.如果我在Windows上更改了系统变量中的某些内容,如何在不退出命令提示符会话并打开另一个命令提示符会话的情况下使其影响当前的命令提示符会话?
我有一个与导入 csv 文件有关的 powershell 问题,然后通过 csv 文件进行 foreach。
我有如下内容:
$infile = "c:\temp\infile.csv"
$outfile = "c:\temp\outfile.csv"
$csv = Import-csv -path $infile
foreach ($line in $csv)
{
$data = Get-ADUser -Filter {EmailAddress -eq $line.email} -Property Mail | Select-Object -ExpandProperty SamAccountName
}
Run Code Online (Sandbox Code Playgroud)
当我做这样的事情时,我收到以下错误:
Get-ADUser : Property: 'email' not found in object of type: 'System.Management.Automation.PSCustomObject'.
At C:\Temp\program1.ps1:11 char:24
+ $ad_data = Get-ADUser <<<< -Filter {EmailAddress -eq $line.email} -Property Mail | Select-Object -ExpandProperty SamAccountName
+ CategoryInfo : InvalidArgument: (:) [Get-ADUser], ArgumentException
+ FullyQualifiedErrorId : Property: …
Run Code Online (Sandbox Code Playgroud)