Powershell Create Object

From Michael's Information Zone
Revision as of 15:21, 6 July 2017 by Michael.mast (talk | contribs) (Created page with "<ref>https://community.spiceworks.com/topic/718753-need-to-output-the-user-input-from-the-powershell-script-to-a-csv</ref> <pre> $FirstName = Read-Host "Enter your First Name"...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

[1]

$FirstName = Read-Host "Enter your First Name"
$LastName = Read-Host "Enter your Last Name"
$Shift = Read-Host "Enter your shift"
$Exmerge = Read-Host "Enter the amount of  Exmerges"
$MessageTrackers = Read-Host "Enter the amount of  MessageTrackers"

New-Object -TypeName PSCustomObject -Property @{    
    FirstName = $FirstName
    LastName = $LastName     
    Shift = $Shift
    Exmerge = $Exmerge
    MessageTrackers = $MessageTrackers
    Date = $ConCurrent
    } | Export-Csv C:\Users\Profile\Desktop\TestOutput_$((Get-Date).ToString('MM-dd-yyyy-hh-mm-ss')).csv -NoTypeInformation