I'm trying to read a .csv with columns CompanyName,UserCount and edit an .rdp file. The output should create multiple .rdp file, while changing 3 lines in the .rdp itself and the name.
So far I have this:
$testRDP = (Get-Content C:\Users\Administrator.PT\Desktop\Test.rdp)
$remoteAPP = @()
$rdpName = @()
$companyNames=Import-Csv C:\Users\Administrator.PT\Desktop\CompanyNames.csv
foreach ($name in $companyNames) {
for ($i = 1; $i -le $name.UserCount; $i++) {
$remoteAPP = "RemoteApp" + $name.CompanyName + ".address.com"
$rdpName = $name.CompanyName + $i + ".rdp"
$aliasRDP = $name.CompanyName + $i
ForEach-Object {$testRDP -replace 'remoteapp.address.com', $remoteAPP}
ForEach-Object {$testRDP -replace 'user', $aliasRDP} |
Out-File C:\Users\Administrator.PT\Desktop\$rdpName
}
}
Running this replaces the 'user' with $aliasRDP but 'remoteapp.address.com' stays the same.
I'm guessing that my pipeline is wrong. If I can clarify something better, let me know.
Thank you.