PowerShell keep text formatting when reading in a file

前端 未结 3 1671
花落未央
花落未央 2021-01-11 10:31

I believe this is a simple question, but I can\'t wrap my head around it. I want to do diagnostic commands in command shell on Windows. Like this:

   $cmd =          


        
3条回答
  •  旧巷少年郎
    2021-01-11 10:52

    Cast to an array of strings, maybe. Like this, for your last example:

    $message = @(Get-Content c:\topsecret\testme.txt)
    

    Or this for the second one:

    $message = [string[]](ipconfig)
    

提交回复
热议问题