script para ativar o serviço ICS

1

Eu tento construir script para selecionar rede privada e ativar parte dos serviços do ICS. Eu seleciono a rede privada com este código:

{
# Constants
$public = 0
$private = 1

Write-Host "Creating netshare object..."
$netshare = New-Object -ComObject HNetCfg.HNetShare

Write-Host "Getting public adapter..."
$publicadapter = $netshare.EnumEveryConnection | Where-Object {
    $netshare.NetConnectionProps($_).Name -eq "Local Area Connection"
}#foreach

Write-Host "Getting private adapter..."
$privateadapter = $netshare.EnumEveryConnection | Where-Object {
    $netshare.NetConnectionProps($_).Name -eq "Peer2Peer"
}#foreach

Write-Host "Disabling sharing for adapters...."
$netshare.INetSharingConfigurationForINetConnection($privateadapter).DisableSharing()
$netshare.INetSharingConfigurationForINetConnection($publicadapter).DisableSharing()

Start-Sleep -s 3

Write-Host "Enabling sharing for private adapter...."
$netshare.INetSharingConfigurationForINetConnection($privateadapter).EnableSharing($private)

Write-Host "Enabling sharing for public adapter...."
$netshare.INetSharingConfigurationForINetConnection($publicadapter).EnableSharing($public)

# Clean up
Remove-Variable netshare
}

Desejo obter todos os serviços do ICS e ativar parte deles alguém tem alguma pista?

    
por user9897732 26.07.2018 / 13:52

0 respostas