PowerShell: Error when Pause is Placed Inside Function

Error:

+ Function Search-ScheduledTasks{
+ ~
Missing closing '}' in statement block or type definition.
At C:\Users\kdoan\Desktop\Notes\test.ps1:57 char:1
+ } #end Search function
+ ~
Unexpected token '}' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MissingEndCurlyBrace

Cause:

Function test{
ping google.com;
pause;
}


Fix: Remove the pause command

Function test{
ping google.com;
}

Leave a Reply

Your email address will not be published. Required fields are marked *