This is the title : "REM not recognized as a command"

Gloops 41 Reputation points
2021-02-23T19:33:16.813+00:00

Hello everybody,

In a Powershell script, I have this :

<#

# # # # # rem Copy-Item -Path Y:\web\$N $path;

>

and at compilation it yells that Rem is not recognized as a command. Well, does this mean that rem is code and not a comment ? How can I solve this ?

My first attempt was just like this :

# rem Copy-Item -Path Y:\web\$N $path;

I have no clue why it appears bold, but at least like that it is clear, as I made three iterations to make the character appear rather than being interpreted as bold.

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,363 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Andreas Baumgarten 96,361 Reputation points MVP
    2021-02-23T19:59:39.417+00:00

    You are talking about PowerShell?
    In PowerShell the # is for comments (one line or in the middle of a line).

    If you like to have more lines in a row as a comment use <# at the beginning and #> at the end.

    # Some examples
    Get-Help # this is a comment following a cmdlet
    
    <#
    This a block where you can comment in lines.
    Just as an example
    #>
    

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards
    Andreas Baumgarten

    0 comments No comments

  2. Gloops 41 Reputation points
    2021-02-23T20:51:38.963+00:00

    Well, as you see, this is exactly what I did.
    But in both cases, REM seems to be refused in a REMARK.


  3. Gloops 41 Reputation points
    2021-02-23T21:08:21.843+00:00

    Hum, it seems it works so long you do not have "REM" in the comment.