none
ERROR: Missing ')' in method call.

    Question

  • Hi I am trying below from a batch file:

    powershell -Command "& {$MyFile = Get-Content %BUILD_DIR%\Oracle\Install\NXG\French_Metadata\NXG_Create_French_Metadata.sql; $Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False;[System.IO.File]::WriteAllLines(%BUILD_DIR%\Oracle\Install\NXG\French_Metadata\NXG_Create_French_Metadata_UTF8.sql, $MyFile, $Utf8NoBomEncoding);}"

    but facing an error 

    Missing ')' in method call.
    At line:1 char:210
    + & {$MyFile = Get-Content ASDBScripts\Oracle\Install\NXG\French_Metadata\NXG_Create_French_Metadata.sql; $Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False;[System.IO.File]::WriteAllLines( <<<< ASDBScripts\Oracle\Install\NXG\French_Metadata\NXG_Create_French_Metadata
    _UTF8.sql, $MyFile, $Utf8NoBomEncoding);}
        + CategoryInfo          : ParserError: (CloseParenToken:TokenId) [], ParentContainsErrorRecordException
        + FullyQualifiedErrorId : MissingEndParenthesisInMethodCall

    Could someone help please?


    Friday, May 18, 2018 1:29 PM

All replies

  • You cannot use %% variables in PowerShell.

    help about_Environment_Variables


    \_(ツ)_/

    Friday, May 18, 2018 2:37 PM
    Moderator
  • To get a long command to work do this:

    powershell -Command "$filename = $env:BUILD_DIR + '\Oracle\Install\NXG\French_Metadata\NXG_Create_French_Metadata_UTF8.sql';(Get-Content $fileName) | Out-File $filename -Encoding  ascii"

    It would be better to place the commands I  a file and test with PowerSHell then use:

    powershell -File file.ps1

    UTF8NoBOM is the same as ASCII in the US but will use the correct code page for Windows.

    Oracle SQL files can use ASCII/Unicode with now issues.

    If you want to conserve French characters then use Unicode and keep the BOM.  It will prevent incorrect conversion of special characters.


    \_(ツ)_/





    Friday, May 18, 2018 2:37 PM
    Moderator