Explain this one to me... When I run commands at the commandline to gather SnapMirror data into a variable, then display it with Format-Table it works great. If I run the same exact commands in a script, I get an error on the Format-Table command. See the examples below. Any ideas?
*** From the commandline
PS C:\Download> $sm = Get-NaSnapmirror
PS C:\Download> $sm | format-table
Source Destination Status State LagTimeTS
------ ----------- ------ ----- ---------
ausap1npsca01_ausad1npsca01_13214... ausad1npsca01:dfm_mirror_ausap1np... idle snapmirrored 00:49:49
ausap1npsca01_ausad1npsca01_13214... ausad1npsca01:dfm_mirror_ausap1np... idle snapmirrored 00:49:15
ausap1npsca01_ausad1npsca01_13214... ausad1npsca01:dfm_mirror_ausap1np... idle snapmirrored 00:50:34
*** The script
# Add the vSphere PowerCLI SnapIn and the DATA ONTAP Module
Import-module DataONTAP
# Use the Show-NaHelp command to show web based documentation on the NetApp Powershell Toolkit
$Filer = "controllername"
# Create a Credential Object for login to the Filer
$Credentials = Get-Credential root
# Connect to NetApp Filer
Connect-NaController $Filer -Credential $Credentials
$SnapMirror = Get-NaSnapmirror
$SnapMirror | format-table
*** Output from the script while running in the Windows Powershell ISE
PS C:\Users\bob.updegraff> C:\Download\SnapMirrorReport.ps1
Name Address Ontapi Version
---- ------- ------ -------
ausad1npsca01 10.1.211.180 1.15 NetApp Release 8.1 7-Mode: Thu Mar 29 13:56:17 PDT 2012
The object of type "Microsoft.PowerShell.Commands.Internal.Format.FormatStartData" is not valid or not in the correct sequence. This is likely caused by a user-specified "format-table" command which is conflicting with the defa
ult formatting.
+ CategoryInfo : InvalidData: (:) [out-lineoutput], InvalidOperationException
+ FullyQualifiedErrorId : ConsoleLineOutputOutOfSequencePacket,Microsoft.PowerShell.Commands.OutLineOutputCommand