Custom column, prefilled

Welcome Forums General PowerShell Q&A Custom column, prefilled

This topic contains 2 replies, has 2 voices, and was last updated by

 
Participant
3 years, 4 months ago.

  • Author
    Posts
  • #30182

    Participant
    Points: 0
    Rank: Member

    Hi,

    I'm doing a get-wmiobject and selecting objects to export to a csv, however I also want a custom column in there with a variable for each row that has data

    So far I have


    $user = [Environment]::UserName

    Get-WmiObject Win32_MappedLogicalDisk | select name, providername | Export-Csv c:\temp\mapped.csv -Append -notypeinformation

    So trying to get a username column in there with each row having $user in

  • #30183

    Participant
    Points: 0
    Rank: Member

    In general when you want to add a custom column you can just add a hashtable to your Select Statement:

    $user = [Environment]::UserName
    
    Get-WmiObject Win32_MappedLogicalDisk | select name, providername,@{Name="Username";Expression={$user}} | Export-Csv c:\temp\mapped.csv -Append -notypeinformation
    
  • #30184

    Participant
    Points: 0
    Rank: Member

    I was so close to getting this one, thank you!

The topic ‘Custom column, prefilled’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort