WMS Anonymous User CustomInterface and PowerShell

This topic contains 0 replies, has 1 voice, and was last updated by  Forums Archives 5 years, 9 months ago.

  • Author
    Posts
  • #5927

    by upinya at 2012-10-03 09:13:31

    [code2=powershell]$Username = "domain\username"
    $Password = "p@55word"
    $WMServer = New-Object -COM WMSServer.Server
    $Plugin = $WMServer.Authenticators.Item("WMS Anonymous User Authentication")
    $Plugin.Enabled = $false
    $AdminAnonUser = $Plugin.CustomInterface
    $AdminAnonUser.SetUserNamePassword($Username, $Password)
    $Plugin.Enabled = $true[/code2]

    Trying to programatically set the Anon user in Windows Media by using COM objects, but I get this error:

    Exception calling "SetUserNamePassword" with "2" argument(s): "Bad variable type. (Exception from HRESULT: 0x80020008 (DISP_E_BADVARTYPE))"
    At line:8 char:35
    + $AdminAnonUser.SetUserNamePassword < <<< ($Username, $Password)
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ComMethodTargetInvocation

    by poshoholic at 2012-10-03 10:18:12

    Just a hunch, have you tried it with a username without the domain? i.e. $Username = "username"?

    by upinya at 2012-10-03 10:37:17

    [quote="poshoholic"]Just a hunch, have you tried it with a username without the domain? i.e. $Username = "username"?[/quote]

    I have done that, yes, I still get the same Bad Variable Type error.

    by poshoholic at 2012-10-03 10:49:26

    My next guess would be something to do with the password. Things I would try:

    1. Try running it from PowerShell in STA mode (i.e. PowerShell -STA). Searching the web for "SetUserNamePassword PowerShell" revealed a discussion from 2008 where that was proposed.

    2. Try a more complex password, possibly longer, in case it has something to do with password restrictions/policy.

    3. Try a password as secure string (i.e. $password = Read-Host -AsSecureString -Prompt 'Enter password:'). I know the docs don't indicate that it expects a secure string, but since it is complaining about type, I thought it could be worth a try.

    by JeffH at 2012-10-03 11:23:57

    Hmmm...my first response never made it. What type of parameters is the method expecting? What do you get from this:

    $AdminAnonUser.SetUserNamePassword.OverLoadDefinitions

    by upinya at 2012-10-03 11:26:32

    [quote="JeffH"]Hmmm...my first response never made it. What type of parameters is the method expecting? What do you get from this:

    $AdminAnonUser.SetUserNamePassword.OverLoadDefinitions[/quote]

    $AdminAnonUser.SetUserNamePassword.OverLoadDefinitions
    void SetUserNamePassword (string, string)

    by upinya at 2012-10-03 12:00:21

    This thread:

    http://www.techtalkz.com/microsoft-wind ... a-com.html

    references THIS thread:

    http://thepowershellguy.com/blogs/posh/ ... vices.aspx

    And the whole thing seems insane to me, much harder than it needs to be 🙁

    by upinya at 2012-10-03 12:07:09

    Here is how to do it with C++ (only very slightly helpful):
    http://msdn.microsoft.com/en-us/library ... 86(v=vs.85).aspx

    Also, this thread mentions this issue specifically:
    http://www.techtalkz.com/microsoft-wind ... a-com.html

    ...which then references this thread for a fix:
    http://thepowershellguy.com/blogs/posh/ ... vices.aspx

    And it leaves me more confused than when I started.

You must be logged in to reply to this topic.