So, the problem is that I must create a 300 ini files. In CSV file I have a computer names and MAC addresses. Ini files must be named as MAC addresses. For that I have solution:
$data = Import-CSV d:\import.csv
ForEach ($i in $data){
$name = $i.name
$MAC = $i.MAC
New-Item -ItemType file -name $_.MAC.ini
}
But in this code I need to put some txt in those inies. For example:
some value
some text
some value=$_.name
and more txt
The content must have the name of computer in some value which is in the same line as MAC address in CSV.
Here I need a help to do it. In first place I tried with Add-Content, but no luck :(
Import-CSV d:\import.csv | %{
"some value`r`nsome text`r`nsome value=$($_.name)`r`nand more txt" | sc "$($_.MAC).ini"
}
% is shorthand for Foreach-Object and sc is an alias for Set-Content.
Be sure your MAC addresses use dashes and not colons, since colons are invalid in filenames.