Get-ComputerInfo | # by default, columns are named "Property" and "Value" ConvertObject-ToHashTable | Out-GridView
Get-WmiObject-Class Win32_BIOS | # specify how you'd like to call the columns displayed in a grid view window ConvertObject-ToHashTable-PropertyName Information -ValueNameData | Out-GridView
# create a hash table where the key is the selected properties to display, # and the value is the original object $hashTable = Get-WmiObject-Class Win32_NetworkAdapterConfiguration | # sort the objects by a property of your choice Sort-Object-Property Description | # use an ordered hash table to keep sort order # (requires PowerShell 3; for older PowerShell remove [Ordered]) ForEach-Object { $ht = [Ordered]@{}}{ # specify the properties that you would like to show in a grid view window $key = $_ | Select-Object-Property Description, IPAddress, MacAddress $ht.Add($key, $_) }{$ht} Group-Object-Property Description, Index -AsHashTable-AsString
# show the keys in the grid view window $hashTable.Keys | Out-GridView-Title"Select Network Card"-OutputMode Single | ForEach-Object { # and retrieve the original (full) object by using # the selected item as key into your hash table $selectedObject = $hashTable[$_] $selectedObject | Select-Object-Property * }
Get-WmiObject-ClassName Win32_UserProfile -Filter"Special=False AND Loaded=False" | Add-Member-MemberType ScriptProperty -Name UserName -Value { (New-Object System.Security.Principal.SecurityIdentifier($this.Sid)).Translate([System.Security.Principal.NTAccount]).Value } -PassThru | Out-GridView-Title"Select User Profile"-OutputMode Single | ForEach-Object { # uncomment the line below to actually remove the selected user profile! #$_.Delete() }
$hashTable.Keys | Sort-Object | Out-GridView-Title"Select User Profile"-OutputMode Single | ForEach-Object { # uncomment the line below to actually remove the selected user profile! # $hashTable[$_].Delete()
Get-WmiObject-ClassName Win32_UserProfile -Filter"Special=False AND Loaded=False" | Add-Member-MemberType ScriptProperty -Name UserName -Value { (New-Object System.Security.Principal.SecurityIdentifier($this.Sid)).Translate([System.Security.Principal.NTAccount]).Value } -PassThru | Out-GridView-Title"Select User Profile"-OutputMode Single | ForEach-Object { # uncomment the line below to actually remove the selected user profile! #$_.Delete() }
Are you an experienced professional PowerShell user? Then learning from default course work isn’t your thing. Consider learning the tricks of the trade from one another! Meet the most creative and sophisticated fellow PowerShellers, along with Microsoft PowerShell team members and PowerShell inventor Jeffrey Snover. Attend this years’ PowerShell Conference EU, taking place April 17-20 in Hanover, Germany, for the leading edge. 35 international top speakers, 80 sessions, and security workshops are waiting for you, including two exciting evening events. The conference is limited to 300 delegates. More details at www.psconf.eu.