locked
Using get-date as variable and passing through to output RRS feed

  • Question

  • Hi, I have this command to get some values:

    $computer = "SRV001"
    get-date($CollectionTime)
    
    Get-WmiObject win32_volume -computer $computer | 
    select PSComputerName ,name, label, 
    @{Name="Capacity (GB)";Expression={[math]::Round($_.Capacity/1GB)}}


    i would like to add one more thing, the "$CollectionTime" value. I am running this command on a lot of computers so i want the value to be the same on all. if i do it like this

    @{Name="CollectionTime"; Expression={get-date}}

    Then the value will change a little bit since this commands takes some seconds.

    • Moved by Bill_Stewart Friday, January 26, 2018 3:45 PM This is not "fix/debug/rewrite my script for me" forum
    Friday, December 22, 2017 10:32 AM

All replies

  • @{Name="CollectionTime"; Expression=$collectionTime}


    \_(ツ)_/

    Friday, December 22, 2017 10:50 AM
  • @{Name="CollectionTime"; Expression=$collectionTime}


    \_(ツ)_/

    select : The "Expression" key has a type, System.DateTime, that is not valid; expected types are {System.String, System.Management.Automation.ScriptBlock}.

    Friday, December 22, 2017 12:13 PM
  • $CollectionTime = get-date

    I highly recommend that you learn PowerShell before trying to copy and use code.  You need to learn what variables are and how to sue them as well as what CmdLets are and how to use them.

    Learn PowerShell


    \_(ツ)_/

    Friday, December 22, 2017 12:36 PM