我正在寻找创建将AD信息输出到特定行的PowerShell脚本。 我仍在研究此问题,但认为询问会产生一些结果。
Import-Module ActiveDirectory
cls
$sid = Read-Host 'What is the username?'
Get-ADUser $sid -Properties * | Select-Object '$nm = GivenName' , Surname, SamAccountName, DisplayName,
City, EmailAddress, EmployeeID, Enabled, OfficePhone, MobilePhone, LockedOut, LockOutTime, AccountExpirationDate, PasswordExpired, PasswordLastSet
cls
Write-Host Name:
Write-Host Email:
Write-Host Phone:
Write-Host User ID:
Write-Host BlueWeb ID:
Write-Host Vendor:
Write-Host Plan:
Write-Host Location:
Write-Host PC_Name/Type:
Write-Host Issue/Request:
Write-Host Previous Ticket:
Write-Host Application:
Write-Host Troubleshooting:
Write-Host Issue after troubleshooting:
我认为我已经接近使用GivenName作为测试所做的事情。我希望将Get-ADUser的结果输出到Write-Host字段。 无论如何,我们将不胜感激。
答案 0 :(得分:0)
对于某些输出非常容易,只需执行以下操作:
$object = Get-ADUser $sid -Properties * | Select-Object '$nm = GivenName' , Surname,
SamAccountName, DisplayName,
City, EmailAddress, EmployeeID, Enabled, OfficePhone, MobilePhone, LockedOut,
LockOutTime, AccountExpirationDate, PasswordExpired, PasswordLastSet
然后使用$ object变量引用所有参数,如下所示:
Write-Host $object.Surname
Write-Host $object.EmailAddress
Write-Host $object.City
您只能引用参数列表中的内容。因此,我不知道您将如何输出“问题/请求”,“上一张票证”等。因为此信息未通过Get-ADUser命令获取。