printing output from select-object with write-host

$lastdir = Get-ChildItem 'C:\Users\' | select Name | sort | select -last 1 name
write-host $lastdir

results printed as @{Name=guptal}

how do I get it just to print the "guptal" part only? How do I access this object values?

April 27th, 2015 7:04pm

Hi,

Add -ExpandProperty to your Select-O

Free Windows Admin Tool Kit Click here and download it now
April 27th, 2015 7:13pm

Or:

(Get-ChildItem C:\Users\ | sort name |select name -last 1).Name

April 28th, 2015 5:11am

This worked as well thanks!
Free Windows Admin Tool Kit Click here and download it now
April 28th, 2015 5:13pm

This works thank you
April 28th, 2015 5:13pm

Cheers, you're very welcome.
Free Windows Admin Tool Kit Click here and download it now
April 28th, 2015 10:42pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics