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

WordPress: Gold Price Widget CSS

Here's a sample of CSS Code to customize the display of the WordPress' Gold Pricing…

PowerShell: check whether the current user is a member of Domain Admins

# short snippet to check whether the currently login user is a domain admin$CurrentUser =…

Microsoft SQL Cloning Database to a Different DB Name

# User defined variables $sourceSqlServer='DEV-SQL01' $sourceDatabaseName='TEST_MSCRM' $sourceSaCredential=$(get-credential) $destinationSqlServer='DEV-SQL01' $destinationDatabaseName='Test_MSCRM' $destinationSaCredential=$(get-credential) function copyDatabase{ param( $sourceSqlServer, $sourceDatabaseName,…