VMware Cloud Community
wolficool
Contributor
Contributor

NTP Service and Firewall Exception

Hello,

i work on a script that schould put out th eStatus of the NTP Service and which Firewall Exceptions are configured wit an HTML Output Table.

But the Problem is that i dont know how can i read the infos out from the ESX Hosts and output to HTML also.

About the NTP Server i dont become an Output when i will put it into the HTML Output Format.

Following Scipt i want to output to HTML Table Format:

Get-VMHost |Sort Name|Select Name, Get-VmHostService | where {$_.name -eq "NTP Client" -and $_.Enabled -eq $true -and $_.ServiceRunning -eq $true}

Thx for your Help

Wolficool

Reply
0 Kudos
5 Replies
LucD
Leadership
Leadership

To get the FW rules you have to use the Get-VMHostFirewallException cmdlet.

For exampe like this.

Get-VMHost |Sort Name|`
Select Name, 
   @{N="NTP FW rule";E={$_ | Get-VMHostFirewallException | where{$_.Name -eq "NTP Client" -and $_.Enabled -and $_.ServiceRunning} |%{"ok"}}}

____________

Blog: LucD notes

Twitter: lucd22


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
wolficool
Contributor
Contributor

Thanks Lucd, but i want it not i a oneline.

I want to output into html if the ntp service is running and one that i can see which firewall exceptions are now configured.

thx

Reply
0 Kudos
RvdNieuwendijk
Leadership
Leadership

To display the output in a web browser, I changed Luc's script into:

Get-VMHost |`
Sort-Object -property Name |`
Select-Object -property Name, @{N="NTP FW rule";E={$_ | Get-VMHostFirewallException | where{$_.Name -eq "NTP Client" -and $_.Enabled -and $_.ServiceRunning} |%{"ok"}}} |`
ConvertTo-html > ntp.htm
Invoke-Item ntp.htm

Regards, Robert

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
Reply
0 Kudos
RvdNieuwendijk
Leadership
Leadership

For a script to see which firewall exceptions are now configured and display the output in a web browser, I came to:

Get-VMHost |`
Sort-Object -property Name |`
ForEach-Object {
  $VMHost = $_.Name
  $FireWallException = $_ | Get-VMHostFirewallException
  $FireWallException | Add-Member -MemberType NoteProperty -Name VMhost -Value $VMhost -PassThru
} |`
Select-Object -property VMhost,name,Enabled,IncomingPorts,OutgoingPorts,Protocols,ServiceRunning |`
ConvertTo-html > firewall.htm
Invoke-Item firewall.htm

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
wolficool
Contributor
Contributor

Perfect Robert Thanks,

Thats what i want Smiley Wink

Reply
0 Kudos