Link to home
Create AccountLog in
Avatar of defecta
defectaFlag for Australia

asked on

PowerShell noob: script optimisation. Is there a better way to do this?

Hey guys,

I am trying to hack my way through teaching myself PowerShell by looking at code examples online and doing a lot of testing and reading. I am also working my way through some books that I bought but I haven't yet learned what a better way to do what I am doing here in this code example.

Basically i want to see ALL the methods and properties and their values listed for the WMI object "Win32_NetworkAdapterConfiguration" in the code example shown below, not just the rather brief version that it returns if no other format parameters are specified.

$member = Get-WmiObject -Class Win32_NetworkAdapterConfiguration -ComputerName $computerName | Where { $_.IPEnabled -eq $enabledAdapters} | get-member

Get-WmiObject -Class Win32_NetworkAdapterConfiguration -ComputerName $computerName | Where { $_.IPEnabled -eq $enabledAdapters} | Format-list $member.name

Open in new window


This code example does what I want but it seems awfully verbose to me. Is there a more clever and concise to acheive the same output?

Cheers,
AC
ASKER CERTIFIED SOLUTION
Avatar of footech
footech
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of defecta

ASKER

Perfect, i knew it was something simple.