Hi, I am trying to write a function which can return the WMI object pointer from a function. Here is my sample code. But it does not return the object reference, it returns the following. \\hostname\root\cimv2:Win32_OperatingSystem=@
I have to explicitly mention the property name individually. e.g. $varobj.BuildNumber
I want to list all the values of each property members. e.g. $varobj.* something like that.
#==================script starts here==========
function fgetOSinfo{
$lobject = Get-WmiObject -ComputerName ukvs01 -Namespace root\cimv2 -Class win32_OperatingSystem
,$lobject
}
$form = New-Object system.Windows.Forms.Form
$btn = New-Object system.Windows.Forms.Button
$btn.TabIndex = 0
$btn.Name = "click me"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 100
$System_Drawing_Size.Height = 50
$btn.Size = $System_Drawing_Size
$btn.Text = "Get OS data"
$btn.add_click({
$varobj=fgetOSinfo
write-host "varObj Type =" $varobj.GetType().FullName
write-host "varobj=$varobj"
write-host $varobj.BuildNumber
}
)
$form.Controls.Add($btn)
$form.ShowDialog()