Solved

Unexpected token 'default" -append  #-ErrorAction silentlycontinue

Posted on 2012-03-09
2
748 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The article will show you how you can maintain a simple logfile of all Startup and Shutdown events on Windows servers and desktops with PowerShell. The script can be easily adapted into doing more like gracefully silencing/updating your monitoring s…
This article will help you understand what HashTables are and how to use them in PowerShell.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

776 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