I have data in AD like below:
DisplayName TelephoneNumber
Alex 111-1111
John 222-2222
Peter 333-3333,2051
I have a powershell script like below:
Get-ADUser -SearchBase 'OU=Domain Users,DC=nxcc,DC=local' -Filter {(enabled -eq $true) -and (mail -like "*.*") -and (PhysicalDeliveryOfficeName -like "*")} -Properties displayname, telephonenumber | select displayname, telephonenumber | Export-csv -NoTypeInformation -encoding UTF8 -Path "\myserverc$AllUserContactInfo.csv"
What I want to do is to add ,0000
at the end of TelephoneNumber
field if the field does not contain a comma character, while exporting to CSV. So expected output is:
DisplayName TelephoneNumber
Alex 111-1111,0000
John 222-2222,0000
Peter 333-3333,2051
How can I achieve this? I appreciate any help.
Regards.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…