Pergunta

I am running PS 4.0 and the following command in interaction with a Veritas Netbackup master server on a Unix host via plink:

PS C:\batch> $testtest = c:\batch\plink blah@blersniggity -pw "blurble" "/usr/openv/netbackup/bin/admincmd/nbpemreq -due -date 01/17/2014" | Format-Table -property Status

As you can see, I attempted a "Format-Table" call at the end of this.

The resulting value of the variable ($testtest) is a string that is laid out exactly like the table in the Unix console, with Status, Job Code, Servername, Policy... all that listed in order. But, it populates the variable in Powershell as just that: a vanilla string.

I want to use this in conjunction with a stored procedure on a SQL box, which would be TONS easier if I could format it into a table. How do I use Powershell to tabulate it exactly how it is extracted from the Unix prompt via Plink?

Foi útil?

Solução

You'll need to parse it and create PS Objects to be able to use the format-* cmdlets. I do enough of it that I wrote this to help:

http://gallery.technet.microsoft.com/scriptcenter/New-PSObjectFromMatches-87d8ce87

You'll need to be able to isolate the data and write a regex to capture the bits you want.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top