Subscribe

Difference between individual commands and putting them together in a script

Hi all,

When I run the below set of command from the CLI they work as expected. But when I run them in the script I do not get any information. Looking for comments on possible causes....

==On CLI==

PS C:\Users\mrinal\Documents\powershell> $vserver_listing = Get-NcVserver -Template

PS C:\Users\mrinal\Documents\powershell> $vserver_listing.VserverType = "data"

PS C:\Users\mrinal\Documents\powershell> $vserver_list = Get-NcVserver -Query $vserver_listing

PS C:\Users\mrinal\Documents\powershell> $vserver_list

Vserver                   State      VserverType   Comment

-------                   -----      -----------   -------

madden-vs1                running    data

madden-vs2                running    data

mrinal-vs02               running    data

rfl_test                  running    data

upper                     running    data

UPPER                     running    data

vs01                      running    data

vs1                       running    data

vs-esrf                   running    data

==Via ps1 script==

PS C:\Users\mrinal\Documents\powershell> .\vserver_dr_collect.ps1

Cluster Name / IP : 10.10.10.10

Cluster Admin UserName : admin

Cluster Admin Password : *********

Name                                    Credential                              HostUser

----                                    ----------                              --------

10.10.10.10                            System.Management.Automation.PSCrede... DOMAIN\dummy

Select Vserver : vs01 <<<<<<< The lines above this are blank on the console as well.

===================================================================

Re: Difference between individual commands and putting them together in a script

Can you attach the script (or a subset that reproduces the problem)?

Thanks!

Re: Difference between individual commands and putting them together in a script

Script attached. I worked around the problem by printing each unit of the array with a foreach loop. Appreciate pointers to improve this logic. Or any other part of the script for that matter.