ChatGPT Powershell Script no working

Hi

I am just learning powershell and trying to write a simple script in Snip.Do which accepts powershell scripts to provide extra functionality.

Task Turn
Suzy Wong
Massive B & Nicodemus
Into
Massive B & Nicodemus - Suzy Wong

I have tried the following from ChatGPT but it is not working
$clip = Get-Clipboard
$clip = $clip -replace “rn”, “-”
Set-Clipboard -Value $clip

Could somebody point me in the right direction please

Desmond,
Welcome back to the forum. :wave:t4: … long time no see … :wink:

Before we proceed …
When you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.

Thanks in advance

How to format code in PowerShell.org <---- Click :point_up_2:t4: :wink:

What’s that?

You know that ChatGPT is not really an experienced developer, don’t you? It is not guaranteed that code genereated by ChatGPT will work.

What would you expect this code to do?

reformat
Suzy Wong
Massive B & Nicodemus
Into
Massive B & Nicodemus Suzy Wong

Wow. You are allowed to use complete sentences and be as verbose as you probably would be when we’d actually talk with each other face to face. :thinking: :man_shrugging:t4:

The code works if the copied text is copied as a raw string including the line breaks - not as an array of lines. For example … if you read the content of a text file with

Get-Content -Path .\SampleText.txt -raw

you can use this code to remove the line breaks and replace them with dashes.

Olaf
So sorry if i did not elaborate.

Thanks for your reply. I have noted all of you points and direction for future reference.

Regards