BReadHeaD
BReadHeaD

Reputation: 11

in powershell Special Variable not working

$_.

I have an order which includes Excel and Powershell.

Here you can see the "tags" im working with

You also may have seen that there are gaps between the 2nd 3rd and 4th. I seem to be having a problem with working these into $_.

import-csv -Path C:\Users\admin.kln\Documents\Project\BOSAN_USERS.csv|foreach{
$Firstname = $_.Firstname
$Lastname = $_.Last_Name
$Displayname = $_.Display_Name
Write-Host $Firstname
}

Its for now a small script but $Firstname gives the outcome of a couple of names below eachother like:

Bastian
Frank
Bob

$LastName, $Last_Name or $Last.Name All have this outcome:




I dont know how to fix this and it would be really helpfull if someone did know!

Thanks for the help beforehand!

Upvotes: 0

Views: 35

Answers (1)

Peter the Automator
Peter the Automator

Reputation: 918

$Lastname = $_."Last Name"

Upvotes: 1

Related Questions