Subscribe

Get-NaSnapmirror truncates output to a file

Hi all,

I am trying to write a PS script to get status of my snapmirrors.

I need Source Volume, Destination Volume, Status, LagTimeTS,  State

However when I view the file the names of the volumes are truncated, and all the columns do not show.

I tried various suggestions I saw from my googled results, but nothing seems to work.

Powershell and I are not well acquainted.

Does anyone have a suggestion ?

thanks!

---- walter

Re: Get-NaSnapmirror truncates output to a file

Hi Walter,

     You need to specify the format settings with powershell.  I don't take credit for the code below as I found it in another post a long time ago.

ft @ means to set format table(ft) using the conditions specified (@).

Expression is the object/property you want to show

Label is what you want it to show

Width sets the column width


$arrays | foreach-object {$c = Connect-NaController $_ -Credential $cred; Get-Nasnapmirror | Where-Object{$_.LagTime -gt $overLag}  | Select Source,Destination,Status,LagtimeTS| `

ft @{Expression={$_.Source};Label="Source";Width=60},@{Expression={$_.Destination};Label="Destination";Width=160},@{Expression={$_.status};Label="status";width=20}, `

@{N='Current Lag Time';E={'{0} days, {1} hrs, {2} mins, {3} secs' -f $_.LagTimeTS.days, $_.LagTimeTS.Hours, $_.LagTimeTS.Minutes, $_.LagTimeTS.Seconds}}}

-Scott

Re: Get-NaSnapmirror truncates output to a file

Thanks Scott,

I finally figured out that I can use foreach-object.and was able to get the info I wanted.

Powershell is overly complex in my opinion.

--- walter