//
stai leggendo...
BLA, domanda, fatto

Select and List

Richard Siddaway's Blog

There are many times when I need to do something like this:

get-Whatever | select –first 1 | format-list –property *

Normally its because I need to discover the properties on an object and see some representative data at the same time. If I  just wanted the properties I could use Get-Member.

Getting tired of typing

select –first 1 | format-list –property *

Its a bit repetitive & boring I decided to look at a function to do this for me and ended up with this

function Select1FullList {
param (
[scriptblock]$scriptblock
)
Invoke-Command -ScriptBlock $scriptblock |
Select-Object -First 1 |
Format-List -Property *
}

New-Alias -Name sfl -Value Select1FullList

I decided on a scriptblock as input because I wasn’t sure what I’d be wanting to see. For instance

Get-mailbox | Get-mailboxstatistics

could be be my input.

I also decided to use an alias as this is a command line…

View original post 46 altre parole

Annunci

Discussione

Non c'è ancora nessun commento.

Rispondi

Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione / Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione / Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione / Modifica )

Google+ photo

Stai commentando usando il tuo account Google+. Chiudi sessione / Modifica )

Connessione a %s...

%d blogger hanno fatto clic su Mi Piace per questo: