# ChatGPT Powershell Script no working

**URL:** <https://forums.powershell.org/t/chatgpt-powershell-script-no-working/21381>\
**Category:** PowerShell Help\
**Created:** [January 17, 2023, 2:23pm UTC](https://forums.powershell.org/t/chatgpt-powershell-script-no-working/21381 "2023-01-17T14:23:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![cldcp00](https://avatars.discourse-cdn.com/v4/letter/c/838e76/32.png) [@cldcp00](https://forums.powershell.org/u/cldcp00)\
**Post date:** [January 17, 2023, 2:23pm UTC](https://forums.powershell.org/t/chatgpt-powershell-script-no-working/21381/1 "2023-01-17T14:23:23Z")

</div>

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 “`r`n”, “-”  
Set-Clipboard -Value $clip

Could somebody point me in the right direction please

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [January 17, 2023, 2:52pm UTC](https://forums.powershell.org/t/chatgpt-powershell-script-no-working/21381/2 "2023-01-17T14:52:37Z")

</div>

Desmond,  
Welcome back to the forum. 👋🏽 … long time no see … 😉

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](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/2X/b/bee50c628238f2c076c0504efb6b15f2fb11f002.gif) \<---- Click 👆🏽 😉

> [@cldcp00](#):
>
> Task Turn  
> Suzy Wong  
> Massive B & Nicodemus  
> Into  
> Massive B & Nicodemus - Suzy Wong

What’s that?

> [@cldcp00](#):
>
> I have tried the following from ChatGPT but it is not working

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

> [@cldcp00](#):
>
> $clip = Get-Clipboard  
> $clip = $clip -replace “`r`n”, “-”  
> Set-Clipboard -Value $clip

What would you expect this code to do?

---

<div class="post-metadata">

**Author:** ![cldcp00](https://avatars.discourse-cdn.com/v4/letter/c/838e76/32.png) [@cldcp00](https://forums.powershell.org/u/cldcp00)\
**Post date:** [January 17, 2023, 4:22pm UTC](https://forums.powershell.org/t/chatgpt-powershell-script-no-working/21381/3 "2023-01-17T16:22:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [January 17, 2023, 4:35pm UTC](https://forums.powershell.org/t/chatgpt-powershell-script-no-working/21381/4 "2023-01-17T16:35:26Z")

</div>

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. 🤔 🤷🏽‍♂️

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

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

```

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

---

<div class="post-metadata">

**Author:** ![cldcp00](https://avatars.discourse-cdn.com/v4/letter/c/838e76/32.png) [@cldcp00](https://forums.powershell.org/u/cldcp00)\
**Post date:** [January 17, 2023, 4:42pm UTC](https://forums.powershell.org/t/chatgpt-powershell-script-no-working/21381/5 "2023-01-17T16:42:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:16pm UTC](https://forums.powershell.org/t/chatgpt-powershell-script-no-working/21381/6 "2024-05-16T20:16:05Z")

</div>


