1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PowerShellで改行コードを\nエスケープシーケンスに変換する

Last updated at Posted at 2019-04-19

Azure Automation(PowerShell)で、SlackのIncoming Webhooksにメッセージを投稿するときに、改行コードを\nエスケープシーケンスに変換したくて調べたときのメモです。

  • こんな環境変数があったとします。
PS> Write-Output $text
aaa
bbb
ccc
  • replaceして$textに設定し直します。
PS> $text = $text -replace "`n","\n"
  • エスケープシーケンスに変換されました。
PS> Write-Output $text
aaa\nbbb\nccc

以上です。

1
3
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?