Link to home
Start Free TrialLog in
Avatar of Member_2_7966113
Member_2_7966113

asked on

How to Powershell Script

Hello Experts,

The attached Powershell script was designed to allow me to see ports that are allowed through a firewall, plus a whole bunch of output. However, when I issue the command Get-RetmoteFirewallStatus the only output I get is True. Can someone let me know what I need to do to get all the other information?

Regards
Get-RemoteFirewallStatus.txt
Avatar of oBdA
oBdA

What exactly did you do to generate this output? Can't reproduce the "True" with the script you posted.
The script as posted only defines a function "Get-RemoteFirewallStatus", it will not do anything by itself when called.
You can now either "dot-source" the script, so that the function Get-RemoteFirewallStatus is available in the PS session afterwards:
# Note the single dot at the beginning of the next line, followed by a space, then the path to the script. THIS IS INTENTIONAL!
. .\Get-RemoteFirewallStatus.ps1
Get-Help Get-RemoteFirewallStatus -ShowWindow
$Status = Get-RemoteFirewallStatus

Open in new window

Or you comment out the very first two lines ("Function Get-RemoteFirewallStatus", "{") and the very last line ("}"), then you can call it directly from the console.
Get-Help .\Get-RemoteFirewallStatus.ps1 -ShowWindow
$Status = .\Get-RemoteFirewallStatus.ps1

Open in new window

Then you can process the output further:
$Status | Select-Object *

Open in new window

$Status.Rules | Format-Table AutoSize

Open in new window

Avatar of Member_2_7966113

ASKER

Hi Thanks for responding,

Please see image to see how I ran the script

User generated image
SOLUTION
Avatar of footech
footech
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi,

OK, so issued the command:

(Get-RemoteFirewallStatus).Rules | where {$_.Active -eq 'TRUE'} | Select Name,Dir

Is that what you referring to?


Cheers
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks guys