Storing entire script inside a variable

Welcome Forums General PowerShell Q&A Storing entire script inside a variable

This topic contains 2 replies, has 3 voices, and was last updated by

 
Participant
3 years, 4 months ago.

  • Author
    Posts
  • #33385

    Participant
    Topics: 7
    Replies: 3
    Points: 0
    Rank: Member

    My problem is I want to store an entire script inside a variable so that I can use invoke-command.

  • #33389

    Participant
    Topics: 16
    Replies: 50
    Points: 58
    Rank: Member

    Posted what I've used in the past from a post on windows it pro. In your GIST

  • #33391

    Participant
    Topics: 1
    Replies: 111
    Points: 89
    Rank: Member

    Yep the simple way is to enclose your block of script inside curly braces then you can assign that to a variable and use that variable. If you've already got a .ps1 script file you could use the -File parameter of Invoke-Command.

The topic ‘Storing entire script inside a variable’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort