Microsoft Virtualization Discussions

PowerShell behaviour


Hello PSTK experts,


I would like seek guidence here. When I run this code just itself it displays all the fields and values. But when it is embeded into a bigger script (similar to 83upgrade check) it just displays the just Vserver value (not even the heading)




$OpenClient = Get-NcExportRule |where-object {$_.ClientMatch -eq "" }
If ($OpenClient) {
write-host "Found export policy with open host access, need fixed or make sure no volume uses these policies" -ForegroundColor Red
$AnyRule = Get-NcExportRule | where-object {$_.ClientMatch -ne "" } | where-object {$_.RwRule -ne "sys" -or $_.RoRule -ne "sys" }
If($AnyRule) {
write-host " "
write-host "Found export policy with open rule access, doesn't fit our standard and need fixed" -ForegroundColor Red

I tried with start-sleep for 2 seconds but same results. Any help would be appreciated.






It's a little hard to troubleshoot if you are giving us working code and then telling us this doesn't work in the larger code.


It is the same code (is working). My problem with the output. When that block of code run alone (pasted on PS command prompt) it works fine. But when it is called after few other functions it shows only vserver data (no headings or other data).




I'm having trouble understanding because we can't see the entire code.  I ran you're code and it does work in my lab exactly as you stated.


If it's part of a larger script, it all depends on how your variables are defined, whether scoped properly.  


If you are not willing to share the entire script, than, at least for myself, I cannot assist


Thanks for you time, again. I think I found the issue. When I changed the preceeding function output, it corrected it self. 

NetApp on Discord Image

We're on Discord, are you?

Live Chat, Watch Parties, and More!

Explore Banner

Meet Explore, NetApp’s digital sales platform

Engage digitally throughout the sales process, from product discovery to configuration, and handle all your post-purchase needs.