What is wrong with this?

Iron Contributor

Hi guys,


Can someone tell me what is wrong with attached script. When I change my own tenant settings and run this, I got below error. I have gone it trought a dosens of times and I just can't see what I'm missing.


I am running this script on SPO shell and trying to list all the Office 365 video portals that I have in the tenant


PS C:\temp> .\ExportVideoChannelsInfoToCSV.ps1
At C:\temp\ExportVideoChannelsInfoToCSV.ps1:54 char:92
+ ... Member –MemberType NoteProperty –Name $group.Title –Value $true
+                                                              ~~~~~~~~~~~~
The string is missing the terminator: ".
At C:\temp\ExportVideoChannelsInfoToCSV.ps1:48 char:31
+ $group.Users | ForEach-Object {
+                               ~
Missing closing '}' in statement block or type definition.
At C:\temp\ExportVideoChannelsInfoToCSV.ps1:45 char:55
+ ForEach($group in @($contributors,$viewers,$creators)){
+                                                       ~
Missing closing '}' in statement block or type definition.
At C:\temp\ExportVideoChannelsInfoToCSV.ps1:31 char:36
+ $results.d.results | ForEach-Object{
+                                    ~
Missing closing '}' in statement block or type definition.
    + CategoryInfo          : ParserError: (:) [], ParseException
    + FullyQualifiedErrorId : TerminatorExpectedAtEndOfString




4 Replies


Here i attached modified script,  it will solve your issue.

Hi Anna-Maria,


You have a problem with encoding where a few dashes (-) are replaced with the text –. This usually happens when copying and pasting text between different programs.

Try using the following code to "fix" the script (UTF8 and default might need other values but I assume these are the ones needed):


$InPath = 'C:\temp\ExportVideoChannelsInfoToCSV.ps1'
$OutPath = 'C:\temp\ExportVideoChannelsInfoToCSV_newencoding.ps1'
Get-Content -Path $InPath -Encoding UTF8 | Out-File -FilePath $OutPath -Encoding default


Or you can use a text editor (like Visual Studio Code) to reopen the file with different encodings until it looks allright.

Thank you so much for helping me out!


I really appreciate it


Thank you so much for explaining what was wrong. It was killing me not knowing.