Page 1 of 1

Dynamic Text for label

Posted: Tue Jun 19, 2012 6:25 am
by StupidSexyFlanders
I need a label that will reflect the current working domain when the form loads (using PSS3.0.4). Here's what I have so far (just showing relevant sections):$OnLoadFormEvent={#TODO: Initialize Form Controls here $getDomain = Get-ChildItem env:USERDOMAIN [string]$D = $getDomain.Value} $DomainName.Font = "Microsoft Sans Serif, 9pt, style=Bold" $DomainName.ForeColor = 'Black' $DomainName.Location = '125, 9' $DomainName.Name = "DomainName" $DomainName.Size = '225, 16' $DomainName.Text = $DIf I replace $Domain.Text = $D with $Domain.Text = "My Domain Name", the label shows that string as its label. But the $D value is not showing at all. When I run this is a PS CLI the value of $D is returned as the proper string.I also tried defining the variables outside the OnFormLoadEvent region and got the same result.

Dynamic Text for label

Posted: Tue Jun 19, 2012 6:28 am
by davidc
It could be that the getDemain variable is null. Try this instead: $env:UserDomain David

Dynamic Text for label

Posted: Tue Jun 19, 2012 7:12 am
by StupidSexyFlanders
Ah, that was the key. I replaced all this:$getDomain = Get-ChildItem env:USERDOMAIN[string]$D = $getDomain.Value$DomainName.Text = $DWith just this: $DomainName.Text = $env:UserDomainThanks!