none
pipeline error when creating a script to change teams upgrade policy RRS feed

  • Question

  • Hello, 

    I am relatively new to creating powershell content, although I have been a user for some time. I have been asked to modify a script that drops a single user into the teams upgrade policy group into one that can do batches of users at one time. 

    Here is the original functioning script

    Import-Module SkypeOnlineConnector
    $sfbSession = New-CsOnlineSession
    Import-PSSession $sfbSession
    $credential = Get-Credential
    $session = New-CsOnlineSession -Credential $credential -Verbose
    Import-PSSession $session
    Grant-CsTeamsupgradePolicy -Identity mfa.test@domain.com -PolicyName upgradetoteams

    here is the modified one as it currently sits

    Import-Module SkypeOnlineConnector -scope currentuser

    Import-CSv -Path "C:\scriptpath\GlobalProtect_Import.csv" 
    | ForEach { $UPN=$_.UserPrincipalName


    $sfbSession = New-CsOnlineSession 
    Import-PSSession $sfbSession 
    $credential = Get-Credential 
    $session = New-CsOnlineSession -Credential $credential -Verbose 
    Import-PSSession $session 
    Grant-CsTeamsupgradePolicy -Identity $UPN -PolicyName upgradetoteams }

    this is the error I get when I try to run it. 

    At C:\scriptpath\Teams_Upgrade.ps1:6 char:1
    + | ForEach { $UPN=$_.UserPrincipalName
    + ~
    An empty pipe element is not allowed.
        + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
        + FullyQualifiedErrorId : EmptyPipeElement

    Can anyone tell me what character seems to be missing or where the issue lies in this script?

    • Edited by Fred0101 Thursday, February 28, 2019 8:18 PM
    Thursday, February 28, 2019 7:46 PM

All replies

  • Try changing that line and the one that precedes it to:

    Import-CSv -Path "C:\scriptpath\GlobalProtect_Import.csv" | ForEach { 
      $UPN=$_.UserPrincipalName


    --- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)

    Thursday, February 28, 2019 8:49 PM
  • Hi,

    Was your issue resolved?

    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.

    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.

    If no, please reply and tell us the current situation in order to provide further help.

    Best Regards,

    Lee


    Just do it.

    Friday, March 1, 2019 6:23 AM
    Moderator