Votre bannière pub ici? contactez nous
Notes
 

Sujet : PowerShell Script to Disable/Re-enable a TCP/IP Port

Affiche les résultats de 1 à 1 sur 1
  1. PowerShell Script to Disable/Re-enable a TCP/IP Port 
    #1
    Administrateur Avatar de chahin
    Inscrit
    novembre 2011
    Messages
    748
    Remerciements
    58
    Remercié(e) 29 fois dans 29 messages
    # Get the IIsWebServer and IIsWebServerSetting WMI objects matching a display name, and combine them into one object
    function Get-IIsWeb
    {
    param (
    [string] $displayName = "",
    [string] $computer = "localhost"
    )

    if ($displayName -eq "")
    { $filter = "" }
    else
    { $filter = "ServerComment='$displayName'"}

    Get-WmiObject -namespace "rootMicrosoftIISv2" -class "IIsWebServerSetting" -filter $filter -computer $computer -authentication 6 | % {
    $temp = $_
    Get-WmiObject -namespace "rootMicrosoftIISv2" -class "IIsWebServer" -filter "Name='$($_.Name)'" -computer $computer -authentication 6 |
    add-member -membertype NoteProperty -name Settings -value $temp -passthru
    }
    }

    # Stop all websites on a given computer that are bound to the specified port, unless they are scoped to a
    # host header or IP address
    function Stop-WebsiteOnPort
    {
    [CmdletBinding()]
    param (
    [Parameter(Mandatory=$true, valuefrompipeline=$true)]
    [int] $port,
    [Parameter(Position=0)]
    [string] $computer = "localhost",
    [Parameter()]
    [string] $hostName = $null,
    [Parameter()]
    [string] $ip = $null
    )

    begin { $websites = Get-IIsWeb -computer $computer }

    process
    {
    # I don't think you can do this filter in WQL
    $websites |
    ? {
    ( $_.settings.serverbindings | ? {$_.port -eq $port -and $_.Hostname -eq $hostName -and $_.IP -eq $ip} | measure).count -gt 0
    } |
    % {
    $_.stop()
    }
    }
    }
     
     

  2. # ADS
    Pub
    Circuit publicitaire
    Inscrit
    Toujours
    Messages
    Plusieurs

    Rappel: N'oubliez pas de remercier les uploaders pour leur travail. Merci à vous

     

Règles des messages
  • Vous ne pouvez pas créer de sujets
  • Vous ne pouvez pas répondre aux sujets
  • Vous ne pouvez pas importer de fichiers joints
  • Vous ne pouvez pas modifier vos messages
  •