Advertisement
Guest User

Untitled

a guest
May 21st, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. Question
  2. Sign in to vote
  3. 0
  4. Sign in to vote
  5. # Get sharing configuration;
  6. $INTERFACE_ID = "{DDA95938-9816-421D-A2C6-36A83DEF6273}";
  7. Write-Output "INTF ID $INTERFACE_ID ";
  8.  
  9. # Create a NetSharingManager object
  10. $MY_NetShare = New-Object -ComObject HNetCfg.HNetShare;
  11.  
  12. if($MY_NetShare.SharingInstalled){
  13. if($Con = $MY_NetShare.EnumEveryConnection | ? { $MY_NetShare.NetConnectionProps.Invoke($_).Guid -eq $INTERFACE_ID }){
  14. $Sharing_Config = $MY_NetShare.INetSharingConfigurationForINetConnection.Invoke($Con);
  15. if($Sharing_Config.SharingEnabled){
  16. $Sharing_Config.DisableSharing()
  17. }else{
  18. Write-Host 'not enabled'
  19. }
  20. }else{
  21. Write-Host 'no connections'
  22. }
  23. }else{
  24. Write-Host 'not installed'
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement