locked
Mutiple Items in a varible in a array RRS feed

  • Question

  • ok normally when I do a array and I have more then one line/item come back i'll do this: 

    gwmi Win32_Volume -computername $hs -filter "DriveType='3'"| % {$run.Volume += $_.DriveLetter}

    this way if there is a C and a D drive it captures both of them and places it in the csv or html 

    but how in the world do I do it if its not a powershell command 

    $run.CheckSDRefDom = (dcdiag /s:$hs /test:CheckSDRefDom |findstr /I /C:"test CheckSDRefDom") -Replace "         .........................",""

    I have this , the output is 

    ForestDnsZones passed test CheckSDRefDom
    DomainDnsZones passed test CheckSDRefDom
    Schema passed test CheckSDRefDom
    Configuration passed test CheckSDRefDom
    doghouse passed test CheckSDRefDom

    Wednesday, January 29, 2020 9:47 PM

All replies

  • had some success

    it was cause it wasn't a string 

    $run.CheckSDRefDom +=[string] (dcdiag /s:$hs /test:CheckSDRefDom |findstr /I /C:"test CheckSDRefDom") -Replace "         .........................",""

    now to have list as 

    ForestDnsZones passed test CheckSDRefDom
    DomainDnsZones passed test CheckSDRefDom
    Schema passed test CheckSDRefDom
    Configuration passed test CheckSDRefDom
    doghouse passed test CheckSDRefDom

    instead of 

    (one Big Line)

    ForestDnsZones passed test CheckSDRefDom DomainDnsZones passed test CheckSDRefDom Schema passed test CheckSDRefDom Configuration passed test CheckSDRefDom doghouse passed test CheckSDRefDom

    Wednesday, January 29, 2020 10:20 PM
  • Interesting explanation even if it is completely wrong.

    This is what you are trying to do.

    (dcdiag  /test:CheckSDRefDom /c | Where{$_ -match '\.\.\..*CheckSDRefDom'}) -replace '\s+\.+\s'


    \_(ツ)_/


    • Edited by jrv Wednesday, January 29, 2020 10:45 PM
    Wednesday, January 29, 2020 10:44 PM