xtodo PowerShell

PowerShell how to connect to a private network drive

New-PSDrive -Name Z -PSProvider FileSystem -Root "//xpc/users/xah/Pictures/"
# 2025-03-09
<#
in PowerShell, how to get "File and Printer Sharing" status

The Get-NetFirewallProfile cmdlet displays the currently configured options for a specified profile.
This cmdlet displays information that is presented on the Windows Firewall with Advanced Security Properties page, with the tabs for Domain, Private, and Public profiles.
The specified profile can be scoped to input rules.

#>

Get-NetFirewallProfile -PolicyStore ActiveStore

# HHHH------------------------------

Get-NetFirewallProfile -Name Public

# big output
Get-NetFirewallProfile -Name Public | Get-NetFirewallRule

# HHHH------------------------------

Get-NetFirewallProfile -Name private

# big output
Get-NetFirewallProfile -Name private | Get-NetFirewallRule
<#
2025-03-09
Get-NetFirewallRule
Retrieves firewall rules from the target computer.

The Get-NetFirewallRule cmdlet returns the instances of firewall rules that match the search parameters from the user. See the New-NetFirewallRule cmdlet for more information.

This cmdlet returns one or more firewall rules by specifying the Name parameter (default), the DisplayName parameter, rule properties, or by associated filters or objects. The queried rules can be placed into variables and piped to other cmdlets for further modifications or monitoring.

#>

Get-NetFirewallRule -PolicyStore ActiveStore

# HHHH------------------------------

Get-NetFirewallProfile -Name Public | Get-NetFirewallRule

# HHHH------------------------------

$nfServiceFilter = Get-NetFirewallRule -Group "@FirewallAPI.dll,-30502" | Get-NetFirewallServiceFilter -Service Any

Set-NetFirewallServiceFilter -Service Ssdpsrv -InputObject $nfServiceFilter

This cmdlet can be run using only the pipeline.
Get-NetFirewallRule -Group "@FirewallAPI.dll,-30502" | Get-NetFirewallServiceFilter -Service Any | Set-NetFirewallServiceFilter -Service Ssdpsrv