![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Retreive wmi data and show it in form label Hi guys, Well, the subject says pretty much everything there is to it: I have a script that generates a form and a label. I also have a gwmi statement that retreives some information (about AD, using an AD-specific cmdlet called "Get-QADUser"). It returns multiple properties (=fields) with multiple values. I want to enumerate this collection (of a single instance, ALWAYS) in the form's label. The relevant code snippet is as follows: # Start of code snippet $objAnswerPanel = New-Object System.Windows.Forms.Label $objAnswerPanel.Location = New-Object System.Drawing.Size(400,50) $objAnswerPanel.Size = New-Object System.Drawing.Size(350,450) $objForm.Controls.Add($objAnswerPanel) $objAnswerPanel.text = get-qaduser -ldapfilter '(samaccountname=johndoe)' # End of code snippet This doesn't work. However, in the powershell console, I get a decent collection out of this statement. So I'm guessing I'm presenting it wrong to the forms' label? It's very hard to find useful information about forms in PowerShell, so I decided to post this question here. Any help is greatly appreciated! Regards, Jeroen |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Retreive wmi data and show it in form label Hi Jeroen, You need to get just the property value you want to set as the label text: $null=[reflection.assembly]::loadwithpartialname("System.Windows.Forms") $objForm = New-Object System.Windows.Forms.Form $objAnswerPanel = New-Object System.Windows.Forms.Label $objAnswerPanel.Size = New-Object System.Drawing.Size 129,50 $objAnswerPanel.Location = New-Object System.Drawing.Size(10,50) $objAnswerPanel.Text = (get-qaduser -samaccountname johndoe).samaccountname $objForm.Controls.Add($objAnswerPanel) $objForm.ShowDialog()| Out-Null --- Shay Levy Windows PowerShell MVP http://blogs.microsoft.co.il/blogs/ScriptFanatic PowerShell Toolbar: http://tinyurl.com/PSToolbar J> Hi guys, J> J> Well, the subject says pretty much everything there is to it: I have J> a script that generates a form and a label. I also have a gwmi J> statement that retreives some information (about AD, using an J> AD-specific cmdlet called "Get-QADUser"). It returns multiple J> properties (=fields) with multiple values. I want to enumerate this J> collection (of a single instance, ALWAYS) in the form's label. J> J> The relevant code snippet is as follows: J> J> # Start of code snippet J> $objAnswerPanel = New-Object System.Windows.Forms.Label J> $objAnswerPanel.Location = New-Object System.Drawing.Size(400,50) J> $objAnswerPanel.Size = New-Object System.Drawing.Size(350,450) J> $objForm.Controls.Add($objAnswerPanel) J> $objAnswerPanel.text = get-qaduser -ldapfilter J> '(samaccountname=johndoe)' J> J> # End of code snippet J> J> This doesn't work. However, in the powershell console, I get a decent J> collection out of this statement. So I'm guessing I'm presenting it J> wrong to the forms' label? It's very hard to find useful information J> about forms in PowerShell, so I decided to post this question here. J> J> Any help is greatly appreciated! J> Regards, J> Jeroen |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Retreive wmi data and show it in form label Shay, Thanks for your reply! I would like to get the whole of the output you'd normally get in PS Console, in the label. Is it possible to either: a) Statically select properties gathered from the gwmi query and append them to the label? b) Enumerate automatically through all properties and put the collection in the label instantly? c) Use a textbox for this instead? Thanks! Jeroen "Shay Levy [MVP]" wrote: Quote: > Hi Jeroen, > > You need to get just the property value you want to set as the label text: > > > $null=[reflection.assembly]::loadwithpartialname("System.Windows.Forms") > $objForm = New-Object System.Windows.Forms.Form > $objAnswerPanel = New-Object System.Windows.Forms.Label > $objAnswerPanel.Size = New-Object System.Drawing.Size 129,50 > $objAnswerPanel.Location = New-Object System.Drawing.Size(10,50) > $objAnswerPanel.Text = (get-qaduser -samaccountname johndoe).samaccountname > $objForm.Controls.Add($objAnswerPanel) > $objForm.ShowDialog()| Out-Null > > > > > > --- > Shay Levy > Windows PowerShell MVP > http://blogs.microsoft.co.il/blogs/ScriptFanatic > PowerShell Toolbar: http://tinyurl.com/PSToolbar > > > > J> Hi guys, > J> > J> Well, the subject says pretty much everything there is to it: I have > J> a script that generates a form and a label. I also have a gwmi > J> statement that retreives some information (about AD, using an > J> AD-specific cmdlet called "Get-QADUser"). It returns multiple > J> properties (=fields) with multiple values. I want to enumerate this > J> collection (of a single instance, ALWAYS) in the form's label. > J> > J> The relevant code snippet is as follows: > J> > J> # Start of code snippet > J> $objAnswerPanel = New-Object System.Windows.Forms.Label > J> $objAnswerPanel.Location = New-Object System.Drawing.Size(400,50) > J> $objAnswerPanel.Size = New-Object System.Drawing.Size(350,450) > J> $objForm.Controls.Add($objAnswerPanel) > J> $objAnswerPanel.text = get-qaduser -ldapfilter > J> '(samaccountname=johndoe)' > J> > J> # End of code snippet > J> > J> This doesn't work. However, in the powershell console, I get a decent > J> collection out of this statement. So I'm guessing I'm presenting it > J> wrong to the forms' label? It's very hard to find useful information > J> about forms in PowerShell, so I decided to post this question here. > J> > J> Any help is greatly appreciated! > J> Regards, > J> Jeroen > > > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Retreive wmi data and show it in form label Like that? $objForm = New-Object System.Windows.Forms.Form $objForm.width=500 $objAnswerPanel = New-Object System.Windows.Forms.Label $objAnswerPanel.Size = New-Object System.Drawing.Size 450,350 $objAnswerPanel.Location = New-Object System.Drawing.Size(10,50) $objAnswerPanel.Text = gps | select name,id | out-string $objForm.Controls.Add($objAnswerPanel) $objForm.ShowDialog()| Out-Null --- Shay Levy Windows PowerShell MVP http://blogs.microsoft.co.il/blogs/ScriptFanatic PowerShell Toolbar: http://tinyurl.com/PSToolbar J> Shay, J> J> Thanks for your reply! J> I would like to get the whole of the output you'd normally get in PS J> Console, in the label. Is it possible to either: J> a) Statically select properties gathered from the gwmi query and J> append them J> to the label? J> b) Enumerate automatically through all properties and put the J> collection in J> the label instantly? J> c) Use a textbox for this instead? J> Thanks! J> Jeroen J> "Shay Levy [MVP]" wrote: J> Quote: Quote: >> Hi Jeroen, >> >> You need to get just the property value you want to set as the label >> text: >> >> $null=[reflection.assembly]::loadwithpartialname("System.Windows.Form >> s") >> $objForm = New-Object System.Windows.Forms.Form >> $objAnswerPanel = New-Object System.Windows.Forms.Label >> $objAnswerPanel.Size = New-Object System.Drawing.Size 129,50 >> $objAnswerPanel.Location = New-Object System.Drawing.Size(10,50) >> $objAnswerPanel.Text = (get-qaduser -samaccountname >> johndoe).samaccountname >> $objForm.Controls.Add($objAnswerPanel) >> $objForm.ShowDialog()| Out-Null >> --- >> Shay Levy >> Windows PowerShell MVP >> http://blogs.microsoft.co.il/blogs/ScriptFanatic >> PowerShell Toolbar: http://tinyurl.com/PSToolbar >> J> Hi guys, >> J> >> J> Well, the subject says pretty much everything there is to it: I >> have >> J> a script that generates a form and a label. I also have a gwmi >> J> statement that retreives some information (about AD, using an >> J> AD-specific cmdlet called "Get-QADUser"). It returns multiple >> J> properties (=fields) with multiple values. I want to enumerate >> this >> J> collection (of a single instance, ALWAYS) in the form's label. >> J> >> J> The relevant code snippet is as follows: >> J> >> J> # Start of code snippet >> J> $objAnswerPanel = New-Object System.Windows.Forms.Label >> J> $objAnswerPanel.Location = New-Object System.Drawing.Size(400,50) >> J> $objAnswerPanel.Size = New-Object System.Drawing.Size(350,450) >> J> $objForm.Controls.Add($objAnswerPanel) >> J> $objAnswerPanel.text = get-qaduser -ldapfilter >> J> '(samaccountname=johndoe)' >> J> >> J> # End of code snippet >> J> >> J> This doesn't work. However, in the powershell console, I get a >> decent >> J> collection out of this statement. So I'm guessing I'm presenting >> it >> J> wrong to the forms' label? It's very hard to find useful >> information >> J> about forms in PowerShell, so I decided to post this question >> here. >> J> >> J> Any help is greatly appreciated! >> J> Regards, >> J> Jeroen |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Retreive wmi data and show it in form label Shay, Hmm why didn't I think of that? Well thanks! One more question though.. I've tried changing the output component to: textbox, label and panel, but none of them are 'scrollable'. Output given IS larger than the output component. Is there any way to make it scrollable? Many thanks! Regards, Jeroen "Shay Levy [MVP]" wrote: Quote: > Like that? > > > $objForm = New-Object System.Windows.Forms.Form > $objForm.width=500 > $objAnswerPanel = New-Object System.Windows.Forms.Label > $objAnswerPanel.Size = New-Object System.Drawing.Size 450,350 > $objAnswerPanel.Location = New-Object System.Drawing.Size(10,50) > $objAnswerPanel.Text = gps | select name,id | out-string > $objForm.Controls.Add($objAnswerPanel) > $objForm.ShowDialog()| Out-Null > > > > > > --- > Shay Levy > Windows PowerShell MVP > http://blogs.microsoft.co.il/blogs/ScriptFanatic > PowerShell Toolbar: http://tinyurl.com/PSToolbar > > > > J> Shay, > J> > J> Thanks for your reply! > J> I would like to get the whole of the output you'd normally get in PS > J> Console, in the label. Is it possible to either: > J> a) Statically select properties gathered from the gwmi query and > J> append them > J> to the label? > J> b) Enumerate automatically through all properties and put the > J> collection in > J> the label instantly? > J> c) Use a textbox for this instead? > J> Thanks! > J> Jeroen > J> "Shay Levy [MVP]" wrote: > J> Quote: Quote: > >> Hi Jeroen, > >> > >> You need to get just the property value you want to set as the label > >> text: > >> > >> $null=[reflection.assembly]::loadwithpartialname("System.Windows.Form > >> s") > >> $objForm = New-Object System.Windows.Forms.Form > >> $objAnswerPanel = New-Object System.Windows.Forms.Label > >> $objAnswerPanel.Size = New-Object System.Drawing.Size 129,50 > >> $objAnswerPanel.Location = New-Object System.Drawing.Size(10,50) > >> $objAnswerPanel.Text = (get-qaduser -samaccountname > >> johndoe).samaccountname > >> $objForm.Controls.Add($objAnswerPanel) > >> $objForm.ShowDialog()| Out-Null > >> --- > >> Shay Levy > >> Windows PowerShell MVP > >> http://blogs.microsoft.co.il/blogs/ScriptFanatic > >> PowerShell Toolbar: http://tinyurl.com/PSToolbar > >> J> Hi guys, > >> J> > >> J> Well, the subject says pretty much everything there is to it: I > >> have > >> J> a script that generates a form and a label. I also have a gwmi > >> J> statement that retreives some information (about AD, using an > >> J> AD-specific cmdlet called "Get-QADUser"). It returns multiple > >> J> properties (=fields) with multiple values. I want to enumerate > >> this > >> J> collection (of a single instance, ALWAYS) in the form's label. > >> J> > >> J> The relevant code snippet is as follows: > >> J> > >> J> # Start of code snippet > >> J> $objAnswerPanel = New-Object System.Windows.Forms.Label > >> J> $objAnswerPanel.Location = New-Object System.Drawing.Size(400,50) > >> J> $objAnswerPanel.Size = New-Object System.Drawing.Size(350,450) > >> J> $objForm.Controls.Add($objAnswerPanel) > >> J> $objAnswerPanel.text = get-qaduser -ldapfilter > >> J> '(samaccountname=johndoe)' > >> J> > >> J> # End of code snippet > >> J> > >> J> This doesn't work. However, in the powershell console, I get a > >> decent > >> J> collection out of this statement. So I'm guessing I'm presenting > >> it > >> J> wrong to the forms' label? It's very hard to find useful > >> information > >> J> about forms in PowerShell, so I decided to post this question > >> here. > >> J> > >> J> Any help is greatly appreciated! > >> J> Regards, > >> J> Jeroen > > |
My System Specs![]() |
| | #6 (permalink) |
| | Re: Retreive wmi data and show it in form label Try this: $textBox.Multiline = $True # scrollbar values #1 - horizontal #2 - vertical #3 - both $textBox1.ScrollBars = 3 --- Shay Levy Windows PowerShell MVP http://blogs.microsoft.co.il/blogs/ScriptFanatic PowerShell Toolbar: http://tinyurl.com/PSToolbar J> Shay, J> J> Hmm why didn't I think of that? J> Well thanks! J> One more question though.. I've tried changing the output component J> to: textbox, label and panel, but none of them are 'scrollable'. J> Output given IS larger than the output component. Is there any way to J> make it scrollable? J> J> Many thanks! J> J> Regards, J> Jeroen J> "Shay Levy [MVP]" wrote: J> Quote: Quote: >> Like that? >> >> $objForm = New-Object System.Windows.Forms.Form >> $objForm.width=500 >> $objAnswerPanel = New-Object System.Windows.Forms.Label >> $objAnswerPanel.Size = New-Object System.Drawing.Size 450,350 >> $objAnswerPanel.Location = New-Object System.Drawing.Size(10,50) >> $objAnswerPanel.Text = gps | select name,id | out-string >> $objForm.Controls.Add($objAnswerPanel) >> $objForm.ShowDialog()| Out-Null >> --- >> Shay Levy >> Windows PowerShell MVP >> http://blogs.microsoft.co.il/blogs/ScriptFanatic >> PowerShell Toolbar: http://tinyurl.com/PSToolbar >> J> Shay, >> J> >> J> Thanks for your reply! >> J> I would like to get the whole of the output you'd normally get in >> PS >> J> Console, in the label. Is it possible to either: >> J> a) Statically select properties gathered from the gwmi query and >> J> append them >> J> to the label? >> J> b) Enumerate automatically through all properties and put the >> J> collection in >> J> the label instantly? >> J> c) Use a textbox for this instead? >> J> Thanks! >> J> Jeroen >> J> "Shay Levy [MVP]" wrote: >> J> Quote: >>>> Hi Jeroen, >>>> >>>> You need to get just the property value you want to set as the >>>> label text: >>>> >>>> $null=[reflection.assembly]::loadwithpartialname("System.Windows.Fo >>>> rm >>>> s") >>>> $objForm = New-Object System.Windows.Forms.Form >>>> $objAnswerPanel = New-Object System.Windows.Forms.Label >>>> $objAnswerPanel.Size = New-Object System.Drawing.Size 129,50 >>>> $objAnswerPanel.Location = New-Object System.Drawing.Size(10,50) >>>> $objAnswerPanel.Text = (get-qaduser -samaccountname >>>> johndoe).samaccountname >>>> $objForm.Controls.Add($objAnswerPanel) >>>> $objForm.ShowDialog()| Out-Null >>>> --- >>>> Shay Levy >>>> Windows PowerShell MVP >>>> http://blogs.microsoft.co.il/blogs/ScriptFanatic >>>> PowerShell Toolbar: http://tinyurl.com/PSToolbar >>>> J> Hi guys, >>>> J> >>>> J> Well, the subject says pretty much everything there is to it: I >>>> have >>>> J> a script that generates a form and a label. I also have a gwmi >>>> J> statement that retreives some information (about AD, using an >>>> J> AD-specific cmdlet called "Get-QADUser"). It returns multiple >>>> J> properties (=fields) with multiple values. I want to enumerate >>>> this >>>> J> collection (of a single instance, ALWAYS) in the form's label. >>>> J> >>>> J> The relevant code snippet is as follows: >>>> J> >>>> J> # Start of code snippet >>>> J> $objAnswerPanel = New-Object System.Windows.Forms.Label >>>> J> $objAnswerPanel.Location = New-Object >>>> System.Drawing.Size(400,50) >>>> J> $objAnswerPanel.Size = New-Object System.Drawing.Size(350,450) >>>> J> $objForm.Controls.Add($objAnswerPanel) >>>> J> $objAnswerPanel.text = get-qaduser -ldapfilter >>>> J> '(samaccountname=johndoe)' >>>> J> >>>> J> # End of code snippet >>>> J> >>>> J> This doesn't work. However, in the powershell console, I get a >>>> decent >>>> J> collection out of this statement. So I'm guessing I'm presenting >>>> it >>>> J> wrong to the forms' label? It's very hard to find useful >>>> information >>>> J> about forms in PowerShell, so I decided to post this question >>>> here. >>>> J> >>>> J> Any help is greatly appreciated! >>>> J> Regards, >>>> J> Jeroen |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Can'T submit form data from mail | Vista mail | |||
| password form data | Vista security | |||
| IE form data transfer to Vista | Vista General | |||
| Importing data form outlook | Vista mail | |||