What is wrong with this?

%3CLINGO-SUB%20id%3D%22lingo-sub-88469%22%20slang%3D%22en-US%22%3EWhat%20is%20wrong%20with%20this%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-88469%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20guys%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECan%20someone%20tell%20me%20what%20is%20wrong%20with%20attached%20script.%20When%20I%20change%20my%20own%20tenant%20settings%20and%20run%20this%2C%20I%20got%20below%20error.%20I%20have%20gone%20it%20trought%20a%20dosens%20of%20times%20and%20I%20just%20can't%20see%20what%20I'm%20missing.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20running%20this%20script%20on%20SPO%20shell%20and%20trying%20to%20list%20all%20the%20Office%20365%20video%20portals%20that%20I%20have%20in%20the%20tenant%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPS%20C%3A%5Ctemp%26gt%3B%20.%5CExportVideoChannelsInfoToCSV.ps1%3CBR%20%2F%3EAt%20C%3A%5Ctemp%5CExportVideoChannelsInfoToCSV.ps1%3A54%20char%3A92%3CBR%20%2F%3E%2B%20...%20Member%20%C3%A2%E2%82%AC%E2%80%9CMemberType%20NoteProperty%20%C3%A2%E2%82%AC%E2%80%9CName%20%24group.Title%20%C3%A2%E2%82%AC%E2%80%9CValue%20%24true%3CBR%20%2F%3E%2B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20~~~~~~~~~~~~%3CBR%20%2F%3EThe%20string%20is%20missing%20the%20terminator%3A%20%22.%3CBR%20%2F%3EAt%20C%3A%5Ctemp%5CExportVideoChannelsInfoToCSV.ps1%3A48%20char%3A31%3CBR%20%2F%3E%2B%20%24group.Users%20%7C%20ForEach-Object%20%7B%3CBR%20%2F%3E%2B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20~%3CBR%20%2F%3EMissing%20closing%20'%7D'%20in%20statement%20block%20or%20type%20definition.%3CBR%20%2F%3EAt%20C%3A%5Ctemp%5CExportVideoChannelsInfoToCSV.ps1%3A45%20char%3A55%3CBR%20%2F%3E%2B%20ForEach(%24group%20in%20%40(%24contributors%2C%24viewers%2C%24creators))%7B%3CBR%20%2F%3E%2B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20~%3CBR%20%2F%3EMissing%20closing%20'%7D'%20in%20statement%20block%20or%20type%20definition.%3CBR%20%2F%3EAt%20C%3A%5Ctemp%5CExportVideoChannelsInfoToCSV.ps1%3A31%20char%3A36%3CBR%20%2F%3E%2B%20%24results.d.results%20%7C%20ForEach-Object%7B%3CBR%20%2F%3E%2B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20~%3CBR%20%2F%3EMissing%20closing%20'%7D'%20in%20statement%20block%20or%20type%20definition.%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%2B%20CategoryInfo%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3A%20ParserError%3A%20(%3A)%20%5B%5D%2C%20ParseException%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%2B%20FullyQualifiedErrorId%20%3A%20TerminatorExpectedAtEndOfString%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-88469%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EWindows%20PowerShell%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-88727%22%20slang%3D%22en-US%22%3ERe%3A%20What%20is%20wrong%20with%20this%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-88727%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you%20so%20much%20for%20explaining%20what%20was%20wrong.%20It%20was%20killing%20me%20not%20knowing.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-88725%22%20slang%3D%22en-US%22%3ERe%3A%20What%20is%20wrong%20with%20this%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-88725%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you%20so%20much%20for%20helping%20me%20out!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20really%20appreciate%20it%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-88521%22%20slang%3D%22en-US%22%3ERe%3A%20What%20is%20wrong%20with%20this%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-88521%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Anna-Maria%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20have%20a%20problem%20with%20encoding%20where%20a%20few%20dashes%20(-)%20are%20replaced%20with%20the%20text%20%C3%A2%E2%82%AC%E2%80%9C.%20This%20usually%20happens%20when%20copying%20and%20pasting%20text%20between%20different%20programs.%3C%2FP%3E%3CP%3ETry%20using%20the%20following%20code%20to%20%22fix%22%20the%20script%20(UTF8%20and%20default%20might%20need%20other%20values%20but%20I%20assume%20these%20are%20the%20ones%20needed)%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%24InPath%20%3D%20'C%3A%5Ctemp%5CExportVideoChannelsInfoToCSV.ps1'%3CBR%20%2F%3E%24OutPath%20%3D%20'C%3A%5Ctemp%5CExportVideoChannelsInfoToCSV_newencoding.ps1'%3CBR%20%2F%3EGet-Content%20-Path%20%24InPath%20-Encoding%20UTF8%20%7C%20Out-File%20-FilePath%20%24OutPath%20-Encoding%20default%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOr%20you%20can%20use%20a%20text%20editor%20(like%20Visual%20Studio%20Code)%20to%20reopen%20the%20file%20with%20different%20encodings%20until%20it%20looks%20allright.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-88494%22%20slang%3D%22en-US%22%3ERe%3A%20What%20is%20wrong%20with%20this%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-88494%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3EHere%20i%20attached%20modified%20script%2C%20%26nbsp%3Bit%20will%20solve%20your%20issue.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
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
Highlighted

Hi,

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

Highlighted

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.

Highlighted

Thank you so much for helping me out!

 

I really appreciate it

 

Highlighted

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