K B
asked on
PowerShell: Add Header to Out-File
This is working but there is no column header, UserPrincipalName. Is there a way to make that happen?
Thank you
$numberofMailboxes = Read-Host "Enter the Number of Mailboxes you want"
$EnterPrefix = Read-Host "Enter the Prefix of the Account"
$Password = Convertto-SecureString "badpasswordbad" -Asplaintext -Force
$GettingEmailSuffix = "contoso.com"
$mail = "@"+"$GettingEmailSuffix"
$ou = "OU=USERS,OU=CORP,DC=corp,DC=ad,DC=contoso,DC=com"
$array =
For($i=0;$i -le $numberofMailboxes;$i++)
{
if ($i -ne "0")
{
$ii = $i.ToString("00")
$UPN = "$EnterPrefix"+"$ii"+"$mail"
$Name = "$EnterPrefix"+"$ii"
write-output $upn
New-RemoteMailbox -UserPrincipalName $UPN -Alias $Name -Name $Name -DisplayName $Name -OnPremisesOrganizationalUnit $ou -Password (ConvertTo-SecureString $Password -AsPlainText -Force) -ResetPasswordOnNextLogon $false -whatif
}
}
$array | Out-File "C:\scripts\licenseme2.csv"
Thank you
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER