I would like ot know if i can take 2 columns from 1 CSV file to create a parameter response in a powershell command.
For example, I have a CSV file containing Ad user data which is ot be used to create accounts.
We have givenname and surname fields.
In the context of this example I want to create form those 2 fields a fullname without the need for an additional column in the CSV file.
I have tried adding to the new-aduser command -name $_.givenname$_.surname however this didn't work.
Is it possible to combine 2 fields in this way or even to combine a string entered into the script with a column from the CSV? (such as a profile path like \\server01\users\$_.samaccountname)
-Name "$($_.givenname) $($_.surname)"
Actually, I seem to be having a problem with this.
the command runs ok but it doesn't give any output. I'm not sur eif it makes any different but the CSV is not piped into the full command. I've added the contents of the CSV to a variable as follows as a test:
$userlist = import-csv c:\Users.csv $output123 = "$($userlist.givenname) $($userlist.surname)"$output123
Combining multiple attributes of an object, which is what you are attempting to do is done as shown by Aleksandar. Wrap the variable and its property in a $() construct, and place that in a string.
Example, you are trying to combine two values of Get-Host:
This is similar to how it would work if you import a csv, for example:
Does that make sense?
Wov, Thank you very much! Now I understand, really cool explanation. THX
Thank you for this, It's clear. :)
You are welcome .)
Your explanation was enlightening, thank you.
I would like to know a little more. I have a two column csv file. The contents of the first column refers to a part of a folder name. The contents of the second column must be processed in the file names which are found in the folders by means of the first column. Do you think this is possible?
Powered by IDERA