Powershell scriptin help

Gautam 41 Reputation points
2020-12-06T19:16:14.753+00:00

$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.

Exchange Server Management
Exchange Server Management
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Management: The act or process of organizing, handling, directing or controlling something.
7,359 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,382 questions
{count} votes

Accepted answer
  1. Rich Matheisen 45,096 Reputation points
    2020-12-06T20:21:19.117+00:00

    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
                }
            }
    
    0 comments No comments

0 additional answers

Sort by: Most helpful