locked
Powershell for users to update their own tel numbers RRS feed

  • Question

  • Hi,

    I am trying to write a script which i can add to the start menu for a self service telephone number update.

    Heres what i have so far, doesn't seem to want to work at the moment, it prompts for the details but thats about it:

     

    Import-Module ActiveDirectory 
    $User = Read-Host -Prompt "Please enter your username"
    $Phone = Read-Host -Prompt "Please enter your phone number"

    Set-ADUser $User.SamAccountName -homePhone $Phone.homePhone 


    Thursday, October 19, 2017 10:15 AM

Answers

  • Do it like this:

    Import-Module ActiveDirectory 
    $User = Read-Host -Prompt "Please enter your username"
    $user = Get-ADUser $User
    $Phone = Read-Host -Prompt "Please enter your phone number"
    
    Set-ADUser $User.SamAccountName -homePhone $Phone


    Please click on Propose As Answer or to mark this post as and helpful for other people. This posting is provided AS-IS with no warranties, and confers no rights.

    • Marked as answer by B_G24 Thursday, October 19, 2017 12:08 PM
    Thursday, October 19, 2017 11:03 AM

All replies

  • Do it like this:

    Import-Module ActiveDirectory 
    $User = Read-Host -Prompt "Please enter your username"
    $user = Get-ADUser $User
    $Phone = Read-Host -Prompt "Please enter your phone number"
    
    Set-ADUser $User.SamAccountName -homePhone $Phone


    Please click on Propose As Answer or to mark this post as and helpful for other people. This posting is provided AS-IS with no warranties, and confers no rights.

    • Marked as answer by B_G24 Thursday, October 19, 2017 12:08 PM
    Thursday, October 19, 2017 11:03 AM
  • And make sure, that the users have the permissions in AD to change the attributes
    Thursday, October 19, 2017 11:43 AM
  • That command will not be available on workstations.

    Download and install the web based user update tools.  It is the easies way to go.


    \_(ツ)_/


    • Edited by jrv Thursday, October 19, 2017 1:21 PM
    Thursday, October 19, 2017 1:19 PM