Forum Discussion
The Foreach loop stopped working after installing edge chromium
- SaraMalhasMay 30, 2020Copper Contributor
me too, I even change the script so many times & used the exchange v2 module also, today I found out only the foreach with office 365 command is failing , adding members to a distribution group is fine.
this is a sample
$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session
Import-CSV "C:\temp\msteams_grp12.csv" | ForEach-Object {
Add-UnifiedGroupLinks –Identity "msteams_grp12fsfs" –LinkType member –Links $_.member
}I even used an identity that doesn't exist to see if I will get an error at least, but it pass by like nothing is there at all,
- Ricardo VianaMay 30, 2020Iron ContributorIt looks completely fine to me, could you double check if the CSV file is comma delimited and not ;? I know it might sound basic, but sometimes it happens(at least it happened to me when I was trying to reproduce your issue), and that's the only place I can see it failing
- SaraMalhasMay 30, 2020Copper Contributor
The thing is, I took the exact same script & the exact same CSV & put it in another workstation & it works fine. I just out of ideas.
& what ever I put in the Foreach loop is doesn't see it at all, like it doesn't exists . I keep putting wrong statement or even hi commands also the same but in the same machine today this script worked
$365Logon = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $365Logon -Authentication Basic -AllowRedirection
Import-PSSession $Session
Import-Csv “C:\Temp\cbe_ped.csv” | foreach{Add-DistributionGroupMember -Identity "cbe_ped" -Member $_.member}