-1

I am trying to do next:

$a = $(Get-ChildItem -Path path | Select-Object -Property creationtime, name, size )
$a.Name
$a.CreationTime
$.Size

I am getting an error.

When I select single attribute - no problem.

Is there a way to select whole object into variable $a?

Clijsters
  • 4,031
  • 1
  • 27
  • 37
gene golub
  • 51
  • 3
  • 7

1 Answers1

2

There are some approaches thinkable:

Get-ChildItem -Path C:\temp -OutVariable ChildItems
$ChildItems.creationtime

Or you can use simply this:

$ChildItems = Get-ChildItem -Path C:\temp 
$ChildItems.creationtime

You should take a little time and learn the basics of Powershell.

Olaf
  • 4,690
  • 2
  • 15
  • 23
  • hello Olaf, thank for recommendation. Can you recommend any book which concentrates on scripting rather then 1 line administrative tasks? – gene golub Feb 07 '18 at 01:12
  • It depends a little bit on your native language I think. For English speakers I've been told that the books from Don Jones used to be very good. So [Learn Windows Powershell in a Month of Lunches](https://www.manning.com/books/learn-windows-powershell-in-a-month-of-lunches-second-edition) or [Powershell Deep Dives](https://www.manning.com/books/powershell-deep-dives). Bruse Payette wrote another good book [Windows PowerShell in Action](https://www.manning.com/books/windows-powershell-in-action-third-edition). – Olaf Feb 07 '18 at 07:14