Posted On March 31, 2019

PowerShell: Error when Pause is Placed Inside Function

kimconnect 0 comments
blog.KimConnect.com >> Codes >> 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 *

Related Post

PowerShell: Special Parameter datatype [switch]

# Demo of a simple function to turn lights on and offfunction setLight{ param( [switch]$on,…

Quick Setup Notes: Install WordPress Using Docker

Obtain SSL Certificate Configure HAProxy Configure MySQL Run Docker Container # Simple WordPress with nothing…

How To Add JavaScript Functions into WordPress

Assuming that the 'Code Snippets' plugin has already been installed, here's a demonstration of adding…