Jump to content
Hak5 Forums
Sign in to follow this  
haze1434

[PowerShell] Best way to copy multiple lines including variables?

Recommended Posts

Hi guys,

Simple PowerShell question; If I want to copy a multi-line set of data to the clipboard, what is the best way to do it?

I have the below at the moment, which successfully copies the data between the braces, however the variable $testing is literally copied as "$testing", and not as "blabla".

Any better way of doing this?

Thanks.

 

$testing = "blabla"
{Testing 1
Testing 2
Testing 3
$testing
etc } | clip

 

Share this post


Link to post
Share on other sites


Have you tried a here-string?

$testing = "blabla"

@"
Testing 1
Testing 2
$testing
Testing 3
"@ | clip

 

  • Like 1

Share this post


Link to post
Share on other sites
2 hours ago, Jason Cooper said:


Have you tried a here-string?

$testing = "blabla"

@"
Testing 1
Testing 2
$testing
Testing 3
"@ | clip

 

 

Perfect, thank you!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×