Advertisement
thebys

potenciál

Jan 10th, 2014
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Register the HNetCfg library (once)
  2. #regsvr32 hnetcfg.dll
  3.  
  4. # Create a NetSharingManager object
  5. $m = New-Object -ComObject HNetCfg.HNetShare
  6.  
  7. # List connections
  8. #$m.EnumEveryConnection |% { $m.NetConnectionProps.Invoke($_) }
  9.  
  10. # Find connection
  11. $c = $m.EnumEveryConnection |? { $m.NetConnectionProps.Invoke($_).Name -eq "Síť Ethernet 2" }
  12.  
  13. # Get sharing configuration
  14. $config = $m.INetSharingConfigurationForINetConnection.Invoke($c)
  15.  
  16. # See if sharing is enabled
  17. Write-Output $config.SharingEnabled
  18. #$config.EnableSharing() ???
  19.  
  20. # See the role of connection in sharing
  21. # 0 - public, 1 - private
  22. # Only meaningful if SharingEnabled is True
  23. Write-Output $config.SharingType
  24.  
  25. # Enable sharing (0 - public, 1 - private)
  26. $config.EnableSharing(0)
  27.  
  28. # Disable sharing
  29. $config.DisableSharing()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement