好吧,我正在尝试弄清楚如何使用PowerShell在电话号码和其他属性中写入AD:
x1c 0d1x的数据
通常情况下,我只是使用一个代码,将采取一个名称和一个号码,并将其应用于移动的,电话,寻呼机等。
Function AddNumberToAD
{
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)]
[Alias('UserInfo')]
[string]$UserNameToAdd,
[Parameter(Mandatory=$true)]
[Alias('PhoneNumber')]
[string]$UsersPhoneNumberToAdd
)
$user = EmailToName $UserNameToAdd
oneEmptyLine
$usersRealName = Get-ADUser -Identity $user -Properties Name
$title = 'Assign Number'
Write-Host "Users Name: ", $usersRealName.Name
write-Host "Username: ", $user
Write-Host "Email: ",$UserNameToAdd
Write-Host "Phone Number to be Added: ",$UsersPhoneNumberToAdd
$question = 'Assign Phone Number as?'
$choices = @(
[System.Management.Automation.Host.ChoiceDescription]::new("&Mobile Number", "Verizon Wireless Number")
[System.Management.Automation.Host.ChoiceDescription]::new("&Telephone Number", "Teams Phone Number")
[System.Management.Automation.Host.ChoiceDescription]::new("&Cancel", "Exit Function")
)
$decision = $Host.UI.PromptForChoice($title, $question, $choices, 2)
if ($decision -eq 0)
{
}
elseif($decision -eq 1)
{
Write-Host "Setting user Telephone Number to Active Directory..." -ForegroundColor Green
Set-ADUser $user -Add @{telephonenumber=$UsersPhoneNumberToAdd}
}
Elseif($decision -eq 2)
{
Return
}
Else
{
Write-Host "Invalid input recieved..." -ForegroundColor Red
字符串
工作得很好,但是我们利用了其他功能,通常将移动的号码与号码匹配:
(忽略3,这只是一个例子)
我想写的脚本,以便它会插入移动的号码到移动的其他属性,但我不知道如何。任何援助将不胜感激。
我已经尝试了-可扩展属性,但我似乎不能使它工作。
我尝试了所有我能想到的方法。只是想让它复制到另一个柱子上,
电话:
1条答案
按热度按时间gxwragnw1#
可用于设置用户的移动的电话的参数为
-MobilePhone
:字符串
如果要使用
-Add
来包含用户的移动的(Other),则需要查看属性的ldapDisplayName,例如,对于移动的(Primary)和移动的(Other),可以使用mobile
和otherMobile
。然而,对于你当前的函数,如果你想一次性设置这两个属性,那么你需要添加一个新的参数来接受这两个值,在这种情况下,我使用
$ParameterForMobile
和$ParameterForOtherMobile
作为占位符。型