GetElementsByName not setting value

I am trying to set a value for a web form. I have followed multiple tutorials with no success. I get the following error

Exception setting "value": "The property 'value' cannot be found on this object. Verify that the property exists and can be set."

Here is my code:

$ie = New-Object -Com "InternetExplorer.Application"
$ie.Navigate("https://*******************/ccmadmin/showHome.do")
$ie.Visible = $true
while($ie.ReadyState -ne 4) {start-sleep -m 100}
$ie.Document.getElementsByName("j_username").value = "aaaaa"

When I get the properties I get the following:

className                    : 
id                           : 
tagName                      : INPUT
parentElement                : System.__ComObject
style                        : System.__ComObject
onhelp                       : 
onclick                      : 
ondblclick                   : 
onkeydown                    : 
onkeyup                      : 
onkeypress                   : 
onmouseout                   : 
onmouseover                  : 
onmousemove                  : 
onmousedown                  : 
onmouseup                    : 
document                     : mshtml.HTMLDocumentClass
title                        : 
language                     : 
onselectstart                : 
sourceIndex                  : 75
recordNumber                 : 
lang                         : 
offsetLeft                   : 1
offsetTop                    : 2
offsetWidth                  : 142
offsetHeight                 : 19
offsetParent                 : System.__ComObject
innerHTML                    : 
innerText                    : 
outerHTML                    : 
outerText                    : 
parentTextEdit               : System.__ComObject
isTextEdit                   : True
filters                      : System.__ComObject
ondragstart                  : 
onbeforeupdate               : 
onafterupdate                : 
onerrorupdate                : 
onrowexit                    : 
onrowenter                   : 
ondatasetchanged             : 
ondataavailable              : 
ondatasetcomplete            : 
onfilterchange               : 
children                     : System.__ComObject
all                          : System.__ComObject
scopeName                    : HTML
onlosecapture                : 
onscroll                     : 
ondrag                       : 
ondragend                    : 
ondragenter                  : 
ondragover                   : 
ondragleave                  : 
ondrop                       : 
onbeforecut                  : 
oncut                        : 
onbeforecopy                 : 
oncopy                       : 
onbeforepaste                : 
onpaste                      : 
currentStyle                 : System.__ComObject
onpropertychange             : 
tabIndex                     : 0
accessKey                    : 
onblur                       : 
onfocus                      : 
onresize                     : 
clientHeight                 : 17
clientWidth                  : 140
clientTop                    : 1
clientLeft                   : 1
readyState                   : complete
onreadystatechange           : 
onrowsdelete                 : 
onrowsinserted               : 
oncellchange                 : 
dir                          : 
scrollHeight                 : 17
scrollWidth                  : 140
scrollTop                    : 0
scrollLeft                   : 0
oncontextmenu                : 
canHaveChildren              : False
runtimeStyle                 : System.__ComObject
behaviorUrns                 : System.__ComObject
tagUrn                       : 
onbeforeeditfocus            : 
isMultiLine                  : False
canHaveHTML                  : False
onlayoutcomplete             : 
onpage                       : 
onbeforedeactivate           : 
contentEditable              : inherit
isContentEditable            : True
hideFocus                    : False
disabled                     : False
isDisabled                   : False
onmove                       : 
oncontrolselect              : 
onresizestart                : 
onresizeend                  : 
onmovestart                  : 
onmoveend                    : 
onmouseenter                 : 
onmouseleave                 : 
onactivate                   : 
ondeactivate                 : 
onmousewheel                 : 
onbeforeactivate             : 
onfocusin                    : 
onfocusout                   : 
uniqueNumber                 : 1
uniqueID                     : ms__id1
nodeType                     : 1
parentNode                   : System.__ComObject
childNodes                   : System.__ComObject
attributes                   : System.__ComObject
nodeName                     : INPUT
nodeValue                    : 
firstChild                   : 
lastChild                    : 
previousSibling              : 
nextSibling                  : 
ownerDocument                : mshtml.HTMLDocumentClass
prefix                       : 
localName                    : 
namespaceURI                 : 
textContent                  : 
dataFld                      : 
dataSrc                      : 
dataFormatAs                 : 
role                         : 
ariaBusy                     : 
ariaChecked                  : 
ariaDisabled                 : 
ariaExpanded                 : 
ariaHaspopup                 : 
ariaHidden                   : 
ariaInvalid                  : 
ariaMultiselectable          : 
ariaPressed                  : 
ariaReadonly                 : 
ariaRequired                 : 
ariaSecret                   : 
ariaSelected                 : 
ie8_attributes               : 
ariaValuenow                 : 
ariaPosinset                 : 
ariaSetsize                  : 
ariaLevel                    : 
ariaValuemin                 : 
ariaValuemax                 : 
ariaControls                 : 
ariaDescribedby              : 
ariaFlowto                   : 
ariaLabelledby               : 
ariaActivedescendant         : 
ariaOwns                     : 
ariaLive                     : 
ariaRelevant                 : 
ie9_tagName                  : 
ie9_nodeName                 : 
onabort                      : 
oncanplay                    : 
oncanplaythrough             : 
onchange                     : 
ondurationchange             : 
onemptied                    : 
onended                      : 
onerror                      : 
oninput                      : 
onload                       : 
onloadeddata                 : 
onloadedmetadata             : 
onloadstart                  : 
onpause                      : 
onplay                       : 
onplaying                    : 
onprogress                   : 
onratechange                 : 
onreset                      : 
onseeked                     : 
onseeking                    : 
onselect                     : 
onstalled                    : 
onsubmit                     : 
onsuspend                    : 
ontimeupdate                 : 
onvolumechange               : 
onwaiting                    : 
constructor                  : 
onmspointerdown              : 
onmspointermove              : 
onmspointerup                : 
onmspointerover              : 
onmspointerout               : 
onmspointercancel            : 
onmspointerhover             : 
onmslostpointercapture       : 
onmsgotpointercapture        : 
onmsgesturestart             : 
onmsgesturechange            : 
onmsgestureend               : 
onmsgesturehold              : 
onmsgesturetap               : 
onmsgesturedoubletap         : 
onmsinertiastart             : 
onmstransitionstart          : 
onmstransitionend            : 
onmsanimationstart           : 
onmsanimationend             : 
onmsanimationiteration       : 
oninvalid                    : 
xmsAcceleratorKey            : 
spellcheck                   : False
onmsmanipulationstatechanged : 
oncuechange                  : 
type                         : text
value                        : 
name                         : j_username
status                       : False
form                         : System.__ComObject
size                         : 20
maxLength                    : 128
defaultValue                 : 
readOnly                     : False
indeterminate                : False
defaultChecked               : False
checked                      : False
border                       : 
vspace                       : 0
hspace                       : 0
alt                          : 
src                          : 
lowsrc                       : 
vrml                         : 
dynsrc                       : 
complete                     : False
loop                         : 1
align                        : 
width                        : 0
height                       : 0
start                        : fileopen
accept                       : 
useMap                       : 
selectionStart               : 
selectionEnd                 : 
ie8_src                      : 
ie8_lowsrc                   : 
ie8_vrml                     : 
ie8_dynsrc                   : 
min                          : 
max                          : 
step                         : 
valueAsNumber                : 

Any thoughts on why I can’t set the value?

It’s probably returning a collection class of some sort, and you want to set the value on an element in that collection. Try this, to be sure:

Get-Member -InputObject $ie.Document.getElementsByName("j_username")

I get the following:

TypeName: System.__ComObject#{3050f56b-98b5-11cf-bb82-00aa00bdce0b}

Name          MemberType Definition                          
----          ---------- ----------                          
ie8_item      Method     IHTMLElement2 ie8_item (int)        
ie8_namedItem Method     IHTMLElement2 ie8_namedItem (string)
item          Method     IDispatch item (Variant, Variant)   
namedItem     Method     IDispatch namedItem (string)        
tags          Method     IDispatch tags (Variant)            
toString      Method     string toString ()                  
urns          Method     IDispatch urns (Variant)            
constructor   Property   IDispatch constructor () {get}      
ie8_length    Property   int ie8_length () {get}             
length        Property   int length () {get} {set}           

Yep, so you probably need to try something like this:

$ie.Document.getElementsByName("j_username").ie8_item(0).value = "aaaaa"

Error

Exception setting "value": "Cannot set the Value property for PSMemberInfo object of type "System.Management.Automation.PSMethod"."

Would there be an easy way to find the index or do I just need to keep trying numbers.