Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <#
- -----------------------------------------------------------------------------------------------------------
- Titre: "FixUp NetFirewallRule Windows 8.1 @ 10.ps1"
- Author: PowerShell_PC_Aide
- PowerShell ver: minimum v5
- version: 20-08-2019
- Dependents: WinRM (Enable-PSRemoting)
- Elevated: Y
- ----------------------------------------------------------------------------------------------------------
- #>
- #cmdlet ActiveDirectory
- Import-Module ActiveDirectory
- #Errors
- $ErrorActionPreference = "SilentlyContinue"
- #File txt sur dossier courant avec script
- #Format: FQDN (E.g.: VM003.golova.com | VM001.brat.com)
- $PCs = Get-Content ".\List PCs.txt"
- #List PCs
- foreach ($PC in $PCs)
- {
- #Online
- $Ping = Test-Connection $PC -Quiet -Count 1
- #True
- if ($Ping)
- {
- #Test-wsMan (WinRM service is running)
- $WSManRunning = Test-WSMan $PC
- #True
- if ($WSManRunning)
- {
- Invoke-Command -ComputerName $PC -ScriptBlock `
- {
- #Variables
- $Seprator = ","
- #Problem (Enabled:True + Action:Block)
- #Sample [*hummingbird exceed 2007*]
- $Condition = Get-NetFirewallRule | Where-Object {$_.Enabled -eq "True" -and $_.Action -eq "Block"}
- #True
- if ($Condition -ne $null)
- {
- #FQDN + SdtOutPut: 1 line by PC
- "FQDN," `
- + "DisplayName," `
- + "Name"
- "$env:COMPUTERNAME.$env:USERDNSDOMAIN," `
- + $Condition.DisplayName + "," `
- + $Condition.Name
- "`n"
- }
- }
- }
- #WinRM not running
- Else
- {
- $PC + ": " + "WinRM is not running"
- }
- }
- #Offline ($Ping = False)
- Else
- {
- (Write-Host $PC -ForegroundColor Red ": " -NoNewline) + "Offline"
- "`n"
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement