终端服务配置文件路径

时间:2017-12-18 21:36:49

标签: powershell active-directory

我正在编写一个powershell脚本来提取我们的活动目录中用户的漫游配置文件路径。但是我收到以下错误消息

def getType():
    print ("<<<<<Apartment Rental Program>>>>>")
    print("       -----------------------")
    print("      Studio --------> 1")
    print("      One Bedroom ---> 2")
    print("      Two Bedroom ---> 3")
    print("      Exit Program --> 4")
    print()
    global choice
    choice= int(input("Enter the type of apartment you wish to rent (1-3 or 4 to exit the program):"))
    global kind
    if choice== 1:
            kind= 'Studio'
    elif choice== 2:
            kind= 'One-Bedroom'
    elif choice== 3:
            kind= 'Two-Bedroom'
    else:
            print("Thank you for inquiring about our apartments for rent!")
            exit()
    while (choice >4 or choice <1):
        print("Invalid apartment type....must be 1-4!")
        choice= int(input("Enter the type of apartment you wish to rent (1-3 or 4 to exit the program):  "))
    if (choice >=1 and choice <=3):
           furn= input("Do you want the apartment furnished (Y/N)?  ")

    global furniture
    def furniture(furn):
        if furn== 'y':
            furniture= 'Furnished'
        elif furn== 'Y':
            furniture= 'Furnished'
        elif furn== 'n':
            furniture= 'Unfurnished'
        elif furn== 'N':
            furniture= 'Unfurnished'
    return kind, furniture #return to function that called them

#use the apartment type and furniture to determine rent and deposit
def determineRent(kind, furniture):
    global rent
    global deposit
    def deposit(kind):
        if kind == 1:
            deposit= 400
        elif kind == 2:
            deposit= 500
        elif kind == 3:
            deposit= 600
    def rent(furniture):
        if (kind)== 1:
            if furniture== 'Furnished':
                        rent= 750
            elif furniture == 'Unfurnished':
                        rent= 600
        elif (kind) == 2:
            if furniture == 'Furnished':
                        rent= 900
            elif furniture == 'Unfurnished':
                        rent= 750
        elif (kind) == 3:
            if furniture == 'Furnished':
                        rent= 1025
            elif furniture == 'Unfurnished':
                        rent= 925
    return rent, deposit #return to the function that called them

#dislpay the users selections and deposit/rent amount based on selections
def displayRent(kind, furniture, rent, deposit):
    if (choice <=3 or choice >=1):
     print("Description:     ", determineRent(kind),determineRent(furniture))
     print("Deposit:         $",determineRent(deposit))
     print("Rent:            $",determineRent(rent))

main()
  

方法调用失败,因为   [System.Management.Automation.PSInternalMemberSet]不包含   方法名为&#39; InvokeGet&#39;。在行:1个字符:1   + $ ADUser.psbase.InvokeGet(“terminalservicesprofilepath”)   + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~       + CategoryInfo:InvalidOperation:(InvokeGet:String)[],RuntimeException       + FullyQualifiedErrorId:MethodNotFound

我不确定如何解决这个问题,或者为什么我要从

开始

1 个答案:

答案 0 :(得分:1)

我认为您可以从Active Directory获取此信息。是不是叫ProfilePath

Get-ADUser nstark -Properties ProfilePath

如果您想通过ADSI获取它,InvokeGet上没有名为psbase的方法。你可以这样称呼它:

$ADUser = Get-ADUser nstark | Select -ExpandProperty DistinguishedName
$ADUser = [ADSI]”LDAP://$ADUser”
$RoamingProfilePath = $ADUser.InvokeGet(“terminalservicesprofilepath”)