Powershell获取AD用户信息

Function get-info {
   foreach ($line in Get-Content $args[0]) {
      $a = Get-ADUser -Filter {samaccountname -eq $line}  -Properties DisplayName,CN,samaccountname  | select DisplayName,CN,samaccountname  
      if ($a -eq $null){
         Write-Output "---"
      }
      else{ 
         Write-Output $a

      }
  } 
}

get-info("D:\1.txt") 

猜你喜欢

转载自blog.51cto.com/magic3/2608866