none
powershell script will not terminate properly - universal dashboard RRS feed

  • Question

  • Hi ppl,

    I am developing a script to create a new user account in AD and have encountered an issue that i hope someone can help with.

    The script is setup to be used with the Universal Dashboard (Community Edition) developed by Adam Driscoll. 

    I can use the current script to perform the following functions:

    • create a new user in an OU of my specification
    • copy groups from one user to the new user
    • create a homedrive folder
    • assign permissions to the homedrive folder based on the new account details

    The issue i am having is when i try and set the Remote Services Profile path.

    When i add the following code, the settings are applied to the new user account, however, the dashboard page will not print the completed status.  Whereas, if i omit the RDS path portion, the script completes properly and i can see the account with all settings applied (minus the RDS as it has been omitted) and the Univ. D/Board displays the completed message.

    In AD, even though the dashboard doesnt show the completed message, the user account has the profile path applied as expected.

    $Dashboard = New-UDDashboard -Title "Test Dashboard" -Content {
    
    New-UDInput -Title "Test Dashboard" -Endpoint {
    
    ## new user creation portion omitted  ##
    
    $DisplayName = "Username"
    $UserID = "userid"
    $OUBase = "path to OU in AD"
    $RemProfPath = "\\server\folder\$UserID"
    
    ##  below is the part of the script that does not allow the dashboard to complete ##
    
    $UserInstancePID = Get-ADUser -SearchBase $OUBase -Filter {displayName -eq $DisplayName} -Properties company, department, distinguishedName, memberof, manager, mobilePhone, OfficePhone, SID, telephoneNumber ,title  | Select-Object  company, department, distinguishedName, memberof, manager, mobilePhone, OfficePhone, SID, telephoneNumber ,title
    $NewUser = [ADSI]"LDAP://$($UserinstancePID.distinguishedName)"
    $NewUser.psbase.invokeset("terminalservicesprofilepath",$RemProfPath)
    $NewUser.setinfo() 
    
    ##  above is the part of the script that does not allow the dashboard to complete ##
    
    New-UDInputAction -Content {
        New-UDCard -Title "Confirmation" -Text "The user account $DisplayName with User ID $UserID has been successfully created." 
            }
        } -Validate
    }
    
    Start-UDDashboard -Dashboard $Dashboard -Port 10001

    Is there something that i am missing with regards to terminating/completing the part of the script that updates the RDS prof. path?

    Your help is appreciated.

    Regards,

    Thursday, December 5, 2019 2:58 AM

All replies

  • For issues with off-market utilities please post to the vendor or author of the product.

    There is no need to use ADSI with this  Just use Set-AdUser.

    Updates to AD may be delayed due to replication and replication issues.


    \_(ツ)_/

    Thursday, December 5, 2019 3:58 AM
  • Hi JRV,

    Unfortunately, this parameter does not exist when using Set-ADUser.

    I am trying to set the terminal services path and not the profile path.

    Unless i am missing something, can you please provide the switch you are referring to?

    Regards,

    Thursday, December 5, 2019 4:18 AM
  • It does. Carefully read the help for the CmdLet.  Use the "Add" or "Replace" parameter.


    \_(ツ)_/

    Thursday, December 5, 2019 4:23 AM
  • i am unable to find the attribute that you say can be applied with the Set-ADUser cmdlet

    are you referring to the 'msTSProfilePath' attribute?

    This is not what i am looking to update.

    I would like to update the following value:

    

    is this something that can be achieved with the set-aduser cmdlet?

    Thursday, December 5, 2019 5:28 AM
  • That is an old property and the ADSI method is the only way to set it.  It appears to be discontinued after WS2012.


    \_(ツ)_/

    Thursday, December 5, 2019 5:47 AM
  • Alternatively, you could use the RDUserSetting PowerShell module I wrote:

    https://github.com/Bill-Stewart/PowerShell-RDUserSetting

    Set-RDUserSetting username dcname -RDProfilePath "path"

    The dcname parameter is the computer name of a domain controller (or a local computer).

    (The module was designed to manage these properties of local accounts, but it works for domain accounts if you specify a domain controller's name for the computer name.)


    -- Bill Stewart [Bill_Stewart]

    Thursday, December 5, 2019 2:44 PM
    Moderator