Capture output from Start-DscConfiguration

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Edwin Ashdown Edwin Ashdown 5 months, 2 weeks ago.

  • Author
    Posts
  • #55182
    Profile photo of Edwin Ashdown
    Edwin Ashdown
    Participant

    Hi All,

    I am trying to capture the output from the Start-DscConfiguration command.
    Seems no matter what i try it just outputs to screen.
    Any help is appreciated.

    Edwin

  • #55190
    Profile photo of Michael Greene
    Michael Greene
    Participant

    It sounds like you are hoping to redirect the verbose stream? If so, using "4>" will be effective. Example:

    Start-DSCConfiguration -Path .\ -Wait -Verbose 4> .\log.txt

  • #55191
    Profile photo of Edwin Ashdown
    Edwin Ashdown
    Participant

    Hi Michael,

    thank you for the reply.

    I just found a post on here this morning that used a similar process and i updated my script with the below as i really needed it in a variable.
    Apparently Start-DscConfiguration does use -OutVariable myVar but i could not get it to populate the variable but the below seems to work nicely.

    $scriptBlock = [scriptblock]::Create("Start-DscConfiguration -Path $MOFFile -Verbose -Wait -Force  4>&1")
    $scriptBlock
    $result.Message = Invoke-Command -ScriptBlock $scriptBlock
    • This reply was modified 5 months, 2 weeks ago by Profile photo of Edwin Ashdown Edwin Ashdown.

You must be logged in to reply to this topic.