1. $ipV6 = Get-NetAdapterBinding | where {$_.ComponentId -eq 'ms_tcpip6'}
    2. set-netadapterbinding -Name $ipV6.Name -ComponentID ms_tcpip6 -Enabled $false
    3. $ipV6.Name
    4. $ipV6.Disabled
    5. function Show-BalloonTip
    6. {
    7. param
    8. (
    9. [Parameter(Mandatory=$true)][string]$Text,
    10. [string]$Title = "项目运营-运维部",
    11. [ValidateSet('Info','Warning','Error','None')][string]$Icon = 'Info'
    12. )
    13. Add-Type -AssemblyName System.Windows.Forms
    14. # we use private variables only. No need for global scope
    15. $balloon = New-Object System.Windows.Forms.NotifyIcon
    16. $cleanup =
    17. {
    18. # this gets executed when the user clicks the balloon tip dialog
    19. # take the balloon from the event arguments, and dispose it
    20. $event.Sender.Dispose()
    21. # take the event handler names also from the event arguments,
    22. # and clean up
    23. Unregister-Event -SourceIdentifier $event.SourceIdentifier
    24. Remove-Job -Name $event.SourceIdentifier
    25. $name2 = "M" + $event.SourceIdentifier
    26. Unregister-Event -SourceIdentifier $name2
    27. Remove-Job -Name $name2
    28. }
    29. $showBalloon =
    30. {
    31. # this gets executed when the user clicks the tray icon
    32. $event.Sender.ShowBalloonTip(5000)
    33. }
    34. # use unique names for event handlers so you can open multiple balloon tips
    35. $name = [Guid]::NewGuid().Guid
    36. # subscribe to the balloon events
    37. $null = Register-ObjectEvent -InputObject $balloon -EventName BalloonTipClicked -Source $name -Action $cleanup
    38. $null = Register-ObjectEvent -InputObject $balloon -EventName MouseClick -Source "M$name" -Action $showBalloon
    39. # use the current application icon as tray icon
    40. $path = (Get-Process -id $pid).Path
    41. $balloon.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($path)
    42. # configure the balloon tip
    43. $balloon.BalloonTipIcon = $Icon
    44. $balloon.BalloonTipText = $Text
    45. $balloon.BalloonTipTitle = $Title
    46. # make the tray icon visible
    47. $balloon.Visible = $true
    48. # show the balloon tip
    49. $balloon.ShowBalloonTip(5000)
    50. }
    51. Show-BalloonTip "IPv6已禁用,请检查网络状态,如有异常,请及时联系郭瑞龙或徐宇坤。"