Solved

Unexpected token 'default" -append  #-ErrorAction silentlycontinue

Posted on 2012-03-09
2
740 Views
Last Modified: 2012-08-13
Hello,

When I execute this script, this error is returned :
Unexpected token 'default" -append  #-ErrorAction silentlycontinue
  }
# Si pas de TCP Port
if ($tcpPort -eq `") {
 "Pas' in expression or statement.
At C:\Temp\test.ps1:103 char:6
+       <<<<  echo $buf | out-file $OUTPUT_FILE -ErrorVariable ERR1 -encoding "default" -append
continue

##############################################################################
# Main Program 
##############################################################################

$tcpPort=(getTcpPort $mach_name $inst_name)
$tcpPort
ForEach($inst in $list_inst) 
{
if ( ( $tcpPort -ne $null) -and ($tcpPort.trim() -ne ""))
  { 
  $buf="`"$mach_name`",`"$inst_name`.$mach_name`",$SNAPID,`"$lsnname$_CPT`",`"$inst_name""

      echo $buf | out-file $OUTPUT_FILE -ErrorVariable ERR1 -encoding "default" -append  #-ErrorAction silentlycontinue
  }
# Si pas de TCP Port
if ($tcpPort -eq "") {
 "Pas de TCP Port"
  exit 2

}
}
}

Open in new window


How can I resolve this problem?

Thanks

bibi
0
Comment
Question by:bibi92
2 Comments
 
LVL 7

Accepted Solution

by:
micropc1 earned 500 total points
ID: 37703899
Have you tried....

echo $buf | out-file $OUTPUT_FILE -ev ERR1 -encoding Default -append -ea SilentlyContinue

Open in new window

0
 

Author Comment

by:bibi92
ID: 37704036
Yes, thanks, I have resolved my problem
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Utilizing an array to gracefully append to a list of EmailAddresses
This script checks a path to see if a folder exists. If the folder does exist you will get output "The folder has previously been created. No action taken" If not it will create the folder. Then adds one user modify permission to the folder. It …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now