Guest User

Untitled

a guest
Jul 15th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. #!C:/PROGRA~1/Perl/bin/perl.exe -w
  2.  
  3. #vraag 17
  4. use Win32::OLE::Const 'Microsoft WMI Scripting';
  5.  
  6. $locator = Win32::OLE->new("WbemScripting.SWbemLocator","localhost");
  7.  
  8. sub GetNameSpaces {
  9. my $naam = shift;
  10. my $niveau = shift;
  11.  
  12. my $con = $locator->ConnectServer(".",$naam);
  13. if(Win32::OLE->QueryObjectType($con)){
  14. for(0..$niveau-1){
  15. print "\t";
  16. }
  17.  
  18.  
  19. my $instances = $con->Get("__NAMESPACE")->Instances_;
  20. print $naam."($instances->{Count})";
  21. #print "\nAantal Instances: " . $instances->{Count} . "\n";
  22.  
  23. foreach(in $instances){
  24. print $_->{Name}."\n";
  25. GetNameSpaces($naam."/".$_->{Name},$niveau+1);
  26. }
  27. }
  28.  
  29. }
  30.  
  31. GetNameSpaces("root",1);
Add Comment
Please, Sign In to add comment