question

gautam2009 avatar image
0 Votes"
gautam2009 asked ·

Powershell scriptin help

$users =(Get-Group "SelectedUsersGroup").members

$users |Get-Recipient | select-object aprimarysmtpaddress |Export-Csv c:\temp\userlist.csv

Then I have to manually format the userlist.csv remove the white spaces, etc. and run the below command

import-csv userlist.csv | %{Grant-CsTeamsVideoInteropServicePolicy -PolicyName PolycomServiceProviderEnabled -Identity $_.PrimarySmtpAddress}


Looking for some help on scripting in which I dont have to export to .csv rather combine line 2 and 3


Thanks for your suggestions.







office-exchange-server-administrationwindows-server-powershell
· 4
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Why do you have to remove whitespace from the PrimarySmtpAddress???? A SMTP address shouldn't contain spaces. What other editing of the CSV file are you doing when you say "etc."?

Have you verified that the group members have been enabled for on-line use?

What are the two asterisks after the ".members" on the 1st line in your example?

0 Votes 0 ·

Why do you have to remove whitespace from the PrimarySmtpAddress???? A SMTP address shouldn't contain spaces. What other editing of the CSV file are you doing when you say "etc."?
-Because the CSV file has white space after each PrimarySmtpAddress


Have you verified that the group members have been enabled for on-line use?
-Yes

What are the two asterisks after the ".members" on the 1st line in your example?
-two asterisks ** resulted while making the text to Bold. Removed now.

0 Votes 0 ·

If the PrimarySmtpAddress in the exported CSV contains a trailing space then try changing your Select-Object to this:

 Select-Object -Expand PrimarySmtpAddress

But there's no need to export the property only to import it later. Instead of using the PrimarySmtpAddress just use the userPrincipalName in your code (see the example in my previous answer).


0 Votes 0 ·

@gautam2009
Hi,
I am writing here to confirm with you how thing going now?
If the issue has been resolved, please mark the helpful replies as answers, this will make answer searching in the forum easier and be beneficial to other community members as well.


If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

0 Votes 0 ·

1 Answer

RichMatheisen-8856 avatar image
0 Votes"
RichMatheisen-8856 answered ·

See if this works for you.

 (Get-Group "SelectedUsersGroup").members |
     Get-Recipient | 
         ForEach-Object{
             Try{
                 Get-CsOnlineUser -Identity $_.userPrincipalName -ErrorAction Stop
                 Grant-CsTeamsVideoInteropServicePolicy -PolicyName PolycomServiceProviderEnabled -Identity $_.userPrincipalName -ErrorAction Stop
             }
             Catch{
                 # you can do something here if you like for group members that aren't enabled
             }
         }
·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.