4 Replies Latest reply on Feb 17, 2016 4:34 AM by RvdNieuwendijk

    Making Long Scripts less "noisy "

    Almero Enthusiast

      Hi Team , any idea on how I can stop and lengthy script from showing all the stuff I set while running . I makes it look very messy . I tried >>Null and [void] methods but those actually stops my commands from creating data . I also picked up that when you create variables , nothing is passed to runtime screens . EG $VMsTOworkWith = Get-VM . But this method is not feasible in this Host build script .

       

       

      Example of some that will return stuff I don't want users to see , I only want Write Host stuff to show .

      Consider I do DNS , NTPTIME , Syslog , Scratch , Networking , you can see how "noisy" this will become .

       

         Get-VMHost | Get-VMHostFirewallException | where {$_.Name.StartsWith('syslog')} | Set-VMHostFirewallException -Enabled $true 

       

         Write-Host "SYSLOG > OPEN FIREWALL ON $ESXi" -ForegroundColor "Yellow" 

       

       

      This shows this on runtime screen ( Windows Poershell ISE )

       

      VMHostId : HostSystem-ha-host

       

      VMHost : TSDESX4

       

      Name : syslog

       

      Enabled : True

       

      IncomingPorts :

       

      OutgoingPorts : 514, 1514

       

      Protocols : UDP, TCP

       

      ServiceRunning :

       

      Uid : /VIServer=root@tsdesx4:443/VMHost=HostSystem-ha-host/VMHostFirewallException=syslog/

       

      ExtensionData : VMware.Vim.HostFirewallRuleset

       

      Client : VMware.VimAutomation.ViCore.Impl.V1.VimClient