×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

WMI Class and Properties Utility

WMI Class and Properties Utility

WMI Class and Properties Utility

(OP)
I noticed that Microsoft took down their link for PowerShell Scriptomatic. I primarily used to use that just to identify properties in a WMI class. So I made the following to replace that utility.

CODE --> PowerShell

#==========================================================================
#
# NAME: WMIClassInfo.ps1
#
# AUTHOR: Mark D. MacLachlan, US Foods
# DATE  : 07/11/2018 14:28:49
#
#    This code is copyright (c) 2018 US Foods.
#
#    All rights reserved.
#
#    THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
#    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
#    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
#    PARTICULAR PURPOSE.
#
#    IN NO EVENT SHALL US FOODS AND/OR ITS RESPECTIVE SUPPLIERS BE
#    LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
#    DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
#    WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
#    ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
#    OF THIS CODE OR INFORMATION.
#
# COMMENT: Displays classes and their properties
#
# MODIFICATIONS: 7/12/2018 Added code to bring form to foreground. Also 
#                added code to refresh text if class is changed.
#==========================================================================

Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.Application]::EnableVisualStyles()

#region begin GUI{ 

$Form                            = New-Object system.Windows.Forms.Form
$Form.ClientSize                 = '400,400'
$Form.text                       = "WMI Class Information"
$Form.TopMost                    = $false

$ListBox1                        = New-Object system.Windows.Forms.ListBox
$ListBox1.text                   = "listBox"
$ListBox1.width                  = 340
$ListBox1.height                 = 30
$ListBox1.location               = New-Object System.Drawing.Point(20,94)

$ClassName                       = New-Object system.Windows.Forms.ComboBox
$ClassName.text                  = "Select Class Name"
$ClassName.width                 = 319
$ClassName.height                = 41
$ClassName.location              = New-Object System.Drawing.Point(44,87)
$ClassName.Font                  = 'Microsoft Sans Serif,10'

$TextBox1                        = New-Object system.Windows.Forms.TextBox
$TextBox1.multiline              = $true
$TextBox1.width                  = 310
$TextBox1.height                 = 164
$TextBox1.location               = New-Object System.Drawing.Point(44,155)
$TextBox1.Font                   = 'Microsoft Sans Serif,10'
$TextBox1.Scrollbars             = 3

$Form.controls.AddRange(@($ClassName,$TextBox1))

#region gui events {
    $TextArray = @()
    $ClassName.Add_SelectedIndexChanged({
    $ActiveClass = $ClassName.SelectedItem
    $ActiveProperties =  get-wmiobject -class $ActiveClass -Property * | sort name |select-object [a-z]*|GM|Select Name
    $TextBox1.Text = ""
    foreach ($property in $ActiveProperties) {#.PSObject.Properties) { 
        Switch ($Property)
        {
            "@{Name=Equals}"{}
            "@{Name=GetHashCode}"{}
            "@{Name=GetType}"{}
            "@{Name=ToString}"{}
            Default{
                $property = $property -Replace "@{Name=",""
                $property = $property -Replace "}",""
                $TextBox1.AppendText($property)
                $TextBox1.AppendText("`n")
            }
        }
    }
  })
#endregion events }

#endregion GUI }


#Write your logic code here

$Classes = (Get-CimClass | Where {$_.CimClassName -match "Win32_"}).CimClassName | Sort-Object
ForEach ($Class in $Classes)
{
 $ClassName.Items.Add($Class)
}

$Form.Add_Shown({$Form.Activate()})
[void]$Form.ShowDialog() 

I hope that helps.

Regards,

Mark

No trees were harmed in posting this message, however a significant number of electrons were terribly inconvenienced.

Check out my scripting solutions at http://www.thespidersparlor.com/vbscript

Work SMARTER not HARDER.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close