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: Query Google Account Using GAM

$emailAddress='[email protected]' $field='accounts:last_login_time' function getGamUser{ param( $emailAddress, $field ) $result=try{gam report users user $emailAddress}catch{} if($result){ $headers=$result[0]…

Apache Hosting Multiple Websites

Must have a FQDN for localhost:vim /etc/hosts---- add this line ----192.168.1.5        server1.cafecenter.com server1----------------------Install GD…

Simple Active Directory & DNS Synchronization Script

@echo offGOTO push_or_pull:push_or_pullset /p action="Type in Push, Pull, or Quit. Press Enter for default action…