Saving a script into a file

Welcome Forums General PowerShell Q&A Saving a script into a file

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

2 years, 3 months ago.

  • Author
  • #64012

    Topics: 1
    Replies: 0
    Points: 0
    Rank: Member

    Hi All,

    Need a little help with something I've been thinking about for sometime.

    May sound silly but will be of great help to me.

  • #64021

    Topics: 0
    Replies: 5
    Points: 0
    Rank: Member

    Can you elaborate more on what you mean?
    Do you mean save an entire script?
    Or save the output?
    Or something else?

  • #64024

    Topics: 2
    Replies: 525
    Points: 24
    Team Member
    Rank: Member

    Hi Joe,

    Not sure why your example and additional text has disappeared but based on what I've in my notification from this forum. I think using a "here"-string would be the easiest option.


    $FolderPath = "C:\Log\Test 1"
    $Source = "D:\Log"
    $script = @"
    MD $folderPath
    xcopy `"$Source`" `"$FolderPath`"
    $script | Out-File -FilePath C:\temp\script.ps1

The topic ‘Saving a script into a file’ is closed to new replies.

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