o n   e r r o r   r e s u m e   n e x t 
 
 ' S t e p s 
 
 ' e n u m e r a t e   f r o m   w i n 3 2 _ g r o u p   w h e r e   l o c a l a c c o u n t = 1 
 
 ' R e a d   i n   t h e   m e m b e r s   o f   e a c h   l o c a l   g r o u p   r e t u r n e d 
 
 ' A d d   t h e   r e t u r n e d   i n f o r m a t i o n   t o   a   c u s t o m   W M I   n a m e s p a c e 
 
 ' s m s - d e f . m o f   t o   p u l l   t h a t   b a c k . 
 
 S e t   f s o   =   C r e a t e O b j e c t ( " S c r i p t i n g . F i l e S y s t e m O b j e c t " )   
 
 S e t   n w o   =   C r e a t e O b j e c t ( " W s c r i p t . N e t w o r k " )   
 
 S e t   s h o   =   C r e a t e O b j e c t ( " W s c r i p t . S h e l l " )   
 
 T e m p F o l d e r   =   s h o . E x p a n d E n v i r o n m e n t S t r i n g s ( " % t e m p % " )   +   " \ " 
 
 s t r W i n d i r   =   s h o . E x p a n d E n v i r o n m e n t S t r i n g s ( " % w i n d i r % " ) 
 
 s t r C o m p u t e r   =   n w o . C o m p u t e r N a m e 
 
 D i m   w b e m C i m t y p e S i n t 1 6   
 
 D i m   w b e m C i m t y p e S i n t 3 2   
 
 D i m   w b e m C i m t y p e R e a l 3 2   
 
 D i m   w b e m C i m t y p e R e a l 6 4   
 
 D i m   w b e m C i m t y p e S t r i n g   
 
 D i m   w b e m C i m t y p e B o o l e a n   
 
 D i m   w b e m C i m t y p e O b j e c t   
 
 D i m   w b e m C i m t y p e S i n t 8   
 
 D i m   w b e m C i m t y p e U i n t 8   
 
 D i m   w b e m C i m t y p e U i n t 1 6   
 
 D i m   w b e m C i m t y p e U i n t 3 2   
 
 D i m   w b e m C i m t y p e S i n t 6 4   
 
 D i m   w b e m C i m t y p e U i n t 6 4   
 
 D i m   w b e m C i m t y p e D a t e T i m e   
 
 D i m   w b e m C i m t y p e R e f e r e n c e   
 
 D i m   w b e m C i m t y p e C h a r 1 6   
 
 
 
 w b e m C i m t y p e S i n t 1 6   =   2   
 
 w b e m C i m t y p e S i n t 3 2   =   3   
 
 w b e m C i m t y p e R e a l 3 2   =   4   
 
 w b e m C i m t y p e R e a l 6 4   =   5   
 
 w b e m C i m t y p e S t r i n g   =   8   
 
 w b e m C i m t y p e B o o l e a n   =   1 1   
 
 w b e m C i m t y p e O b j e c t   =   1 3   
 
 w b e m C i m t y p e S i n t 8   =   1 6   
 
 w b e m C i m t y p e U i n t 8   =   1 7   
 
 w b e m C i m t y p e U i n t 1 6   =   1 8   
 
 w b e m C i m t y p e U i n t 3 2   =   1 9   
 
 w b e m C i m t y p e S i n t 6 4   =   2 0   
 
 w b e m C i m t y p e U i n t 6 4   =   2 1   
 
 w b e m C i m t y p e D a t e T i m e   =   1 0 1   
 
 w b e m C i m t y p e R e f e r e n c e   =   1 0 2   
 
 w b e m C i m t y p e C h a r 1 6   =   1 0 3   
 
 ' - - - - - - - - - - - - - - 
 
 ' N e w   L o g g i n g   S e c t i o n 
 
 ' - - - - - - - - - - - - - - 
 
 s t r L o g N a m e   =   T e m p F o l d e r   &   " S C C M L o c a l G r o u p M e m b e r s . l o g " 
 
 i f   ( f s o . f i l e e x i s t s ( s t r L o g N a m e ) )   t h e n   f s o . d e l e t e f i l e ( s t r L o g N a m e )   e n d   i f 
 
 s e t   L o g g i n g   =   f s o . O p e n T e x t f i l e ( s t r L o g N a m e , 8 , T r u e ) 
 
 L o g g i n g . W r i t e L i n e ( N o w   &   "   -   "   &   " S c r i p t   S t a r t e d " ) 
 
 
 
 '   R e m o v e   c l a s s e s   
 
 S e t   o L o c a t i o n   =   C r e a t e O b j e c t ( " W b e m S c r i p t i n g . S W b e m L o c a t o r " )   
 
 ' = = = = = = = = = = = = = = = = = = = 
 
 ' I f   t h i s   i s   a   D o m a i n   C o n t r o l l e r ,   b a i l ! 
 
 ' = = = = = = = = = = = = = = = = = = = 
 
 S e t   o W M I   =   G e t O b j e c t ( " w i n m g m t s : "   _ 
 
 &   " { i m p e r s o n a t i o n L e v e l = i m p e r s o n a t e } ! \ \ . \ r o o t \ c i m v 2 " ) 
 
 S e t   c o l C o m p u t e r   =   o W M I . E x e c Q u e r y   _ 
 
 ( " S e l e c t   D o m a i n R o l e   f r o m   W i n 3 2 _ C o m p u t e r S y s t e m " ) 
 
 F o r   E a c h   o C o m p u t e r   i n   c o l C o m p u t e r 
 
   i f   ( o C o m p u t e r . D o m a i n R o l e   =   4   o r   o C o m p u t e r . D o m a i n R o l e   =   5 )   t h e n 
 
 L o g g i n g . W r i t e L i n e ( N o w   &   "   -   "   &   " D o m a i n   C o n t r o l l e r ,   Q u i t t i n g " ) 
 
       ' w s c r i p t . q u i t 
 
   E l s e 
 
 L o g g i n g . W r i t e L i n e ( N o w   &   "   -   "   &   " N o t   a   D o m a i n   C o n t r o l l e r ,   C o n t i n u i n g " ) 
 
 ' = = = = = = = = = = = = = = = = = = 
 
 ' I f   i t   i s   N O T   a   d o m a i n   c o n t r o l l e r ,   t h e n   c o n t i n u e   g a t h e r i n g   i n f o   
 
 ' a n d   s t u f f   i t   i n t o   W M I   f o r   l a t e r   e a s y   r e t r i e v a l 
 
 ' = = = = = = = = = = = = = = = = = = 
 
 
 
 S e t   o S e r v i c e s   =   o L o c a t i o n . C o n n e c t S e r v e r ( , " r o o t \ c i m v 2 " )   
 
 s e t   o N e w O b j e c t   =   o S e r v i c e s . G e t ( " C M _ L o c a l G r o u p M e m b e r s " )   
 
 o N e w O b j e c t . D e l e t e _   
 
 L o g g i n g . W r i t e L i n e ( N o w   &   "   -   "   &   " C l e a n e d   c m _ l o c a l g r o u p m e m b e r s ,   i f   i t   e x i s t e d . " ) 
 
 ' = = = = = = = = = = = = = = = = = = 
 
 ' G e t   t h e   l o c a l   G r o u p   N a m e s 
 
 ' = = = = = = = = = = = = = = = = = = 
 
 D i m   i G r o u p s ( 3 0 0 ) 
 
 i = 0 
 
 S e t   o b j W M I S e r v i c e   =   G e t O b j e c t ( " w i n m g m t s : "   _ 
 
                 &   " { i m p e r s o n a t i o n L e v e l = i m p e r s o n a t e } ! \ \ . \ r o o t \ c i m v 2 " ) 
 
 S e t   c o l G r o u p   =   o b j W M I S e r v i c e . E x e c Q u e r y ( " s e l e c t   *   f r o m   w i n 3 2 _ g r o u p   w h e r e   l o c a l a c c o u n t = 1 " ) 
 
 f o r   e a c h   o b j   i n   c o l G r o u p 
 
     i g r o u p s ( i ) = o b j . N a m e 
 
     i = i + 1 
 
 n e x t 
 
 L o g g i n g . W r i t e L i n e ( N o w   &   "   -   "   &   " F o u n d   "   &   i   &   "   L o c a l   G r o u p s " ) 
 
 ' = = = = = = = = = = = = = = = 
 
 ' G e t   a l l   o f   t h e   n a m e s   w i t h i n   e a c h   g r o u p 
 
 d i m   s t r L o c a l ( 3 0 0 ) 
 
 k = 0 
 
 S e t   o L o c a t i o n   =   C r e a t e O b j e c t ( " W b e m S c r i p t i n g . S W b e m L o c a t o r " )   
 
 S e t   o S e r v i c e s   =   o L o c a t i o n . C o n n e c t S e r v e r ( ,   " r o o t \ c i m v 2 "   )   
 
 
 
 ' g r o u p   n a m e ,   d o m a i n   n a m e ,   u s e r   o r   g r o u p 
 
 f o r   j   =   0   t o   i - 1 
 
 
 
 s q u e r y   =   " s e l e c t   p a r t c o m p o n e n t   f r o m   w i n 3 2 _ g r o u p u s e r   w h e r e   g r o u p c o m p o n e n t   =   " " \ \ \ \ "   & _ 
 
   s t r C o m p u t e r   &   " \ \ r o o t \ \ c i m v 2 : W i n 3 2 _ G r o u p . D o m a i n = \ " " "   &   s t r C o m p u t e r   & _ 
 
   " \ " " , N a m e = \ " " "   & i g r o u p s ( j )   &   " \ " " " " "   
 
 
 
 S e t   o I n s t a n c e s   =   o S e r v i c e s . E x e c Q u e r y ( s Q u e r y )   
 
   F O R   E A C H   o O b j e c t   i n   o I n s t a n c e s   
 
     s t r L o c a l ( k ) = i g r o u p s ( j )   &   " ! "   &   o O b j e c t . P a r t C o m p o n e n t 
 
 
 
     k = k + 1 
 
 
 
   N e x t 
 
 n e x t 
 
 L o g g i n g . W r i t e L i n e ( N o w   &   "   -   "   &   " F o u n d   a   t o t a l   o f   "   &   k - 1   &   "   N a m e s   w i t h i n   t h o s e   "   &   i   &   "   g r o u p s " ) 
 
 ' = = = = = = = = = = = = = = = = = = 
 
 ' D r o p   t h a t   i n t o   a   c u s t o m   w m i   N a m e s p a c e 
 
 ' = = = = = = = = = = = = = = = = = = 
 
 
 
 
 
 '   C r e a t e   d a t a   c l a s s   s t r u c t u r e   
 
 S e t   o D a t a O b j e c t   =   o S e r v i c e s . G e t   
 
 o D a t a O b j e c t . P a t h _ . C l a s s   =   " C M _ L o c a l G r o u p M e m b e r s "   
 
 o D a t a O b j e c t . P r o p e r t i e s _ . a d d   " A c c o u n t "   ,   w b e m C i m t y p e S t r i n g   
 
 o D a t a O b j e c t . P r o p e r t i e s _ ( " A c c o u n t " ) . Q u a l i f i e r s _ . a d d   " k e y "   ,   T r u e   
 
 o D a t a O b j e c t . P r o p e r t i e s _ . a d d   " D o m a i n "   ,   w b e m C i m t y p e S t r i n g 
 
 o D a t a O b j e c t . P r o p e r t i e s _ ( " D o m a i n " ) . Q u a l i f i e r s _ . a d d   " k e y "   ,   T r u e 
 
 o D a t a O b j e c t . P r o p e r t i e s _ . a d d   " C a t e g o r y "   ,   w b e m C i m t y p e S t r i n g 
 
 o D a t a O b j e c t . P r o p e r t i e s _ . a d d   " T y p e "   ,   w b e m C i m t y p e S t r i n g 
 
 o D a t a O b j e c t . P r o p e r t i e s _ . a d d   " N a m e "   ,   w b e m C i m t y p e S t r i n g 
 
 o D a t a O b j e c t . P r o p e r t i e s _ ( " N a m e " ) . Q u a l i f i e r s _ . a d d   " k e y "   ,   T r u e 
 
 o D a t a O b j e c t . P u t _   
 
 
 
 L o g g i n g . W r i t e L i n e ( N o w   &   "   -   "   &   " S t a r t i n g   t o   p o p u l a t e   c m _ l o c a l g r o u p m e m b e r s " ) 
 
 f o r   m   =   0   t o   k - 1 
 
 S e t   o N e w O b j e c t   =   o S e r v i c e s . G e t ( " C M _ L o c a l G r o u p M e m b e r s "   ) . S p a w n I n s t a n c e _   
 
 s t r 0   =   S p l i t ( s t r L o c a l ( m ) ,   " ! " ,   - 1 ,   1 ) 
 
 s t r 1   =   S p l i t ( s t r L o c a l ( m ) ,   " , " ,   - 1 , 1 ) 
 
 s t r 2   =   S p l i t ( s t r 1 ( 0 ) ,   " \ "   ,   - 1 ,   1 )   
 
 s t r 4   =   S p l i t ( s t r 2 ( 4 ) ,   C h r ( 3 4 ) ,   - 1 ,   1 )   
 
 
 
 
 
 '   T h e   A c c o u n t   n a m e   o r   G r o u p   N a m e   i s   i n s i d e   t h e   q u o t e s   a f t e r   t h e   c o m m a   
 
 s t r 3   =   S p l i t ( s t r 1 ( 1 ) ,   C h r ( 3 4 ) ,   - 1 ,   1 )   
 
 '   i f   t h e   w m i   s o u r c e   n a m e   i s   t h e   s a m e   a s   t h e   d o m a i n   n a m e   i n s i d e   t h e   q u o t e s ,   i t '   s   a   l o c a l   a c c o u n t   
 
 '   s t r 2 ( 2 )   i s   t h e   w m i   s o u r c e   n a m e ,   s t r 4 ( 1 )   i s   t h e   d o m a i n   n a m e   i n s i d e   t h e   q u o t e s .   
 
 I f   l c a s e ( s t r 2 ( 2 ) )   =   l c a s e ( s t r 4 ( 1 ) )   T h e n   
 
 o N e w O b j e c t . T y p e   =   " L o c a l "   
 
 E l s e   
 
 o N e w O b j e c t . T y p e   =   " D o m a i n "   
 
 E n d   I f 
 
 o N e w O b j e c t . D o m a i n   =   s t r 4 ( 1 )   
 
 o N e w O b j e c t . A c c o u n t   =   s t r 3 ( 1 )   
 
 o N e w O b j e c t . N a m e   =   s t r 0 ( 0 ) 
 
 S e l e c t   C a s e   l c a s e ( s t r 4 ( 0 ) ) 
 
     c a s e   " c i m v 2 : w i n 3 2 _ u s e r a c c o u n t . d o m a i n = " 
 
       o N e w O b j e c t . C a t e g o r y   =   " U s e r A c c o u n t " 
 
     C a s e   " c i m v 2 : w i n 3 2 _ g r o u p . d o m a i n = " 
 
       o N e w O b j e c t . C a t e g o r y   =   " G r o u p " 
 
     C a s e   " c i m v 2 : w i n 3 2 _ s y s t e m a c c o u n t . d o m a i n = " 
 
       o N e w O b j e c t . C a t e g o r y   =   " S y s t e m A c c o u n t " 
 
     c a s e   e l s e 
 
       o N e w O b j e c t . C a t e g o r y   =   " u n k n o w n " 
 
 e n d   s e l e c t 
 
 o N e w O b j e c t . P u t _   
 
 N e x t 
 
 L o g g i n g . W r i t e L i n e ( N o w   &   "   -   "   &   " C o m p l e t e d   p o p u l a t i n g   c m _ l o c a l g r o u p m e m b e r s " ) 
 
 
 
   e n d   i f 
 
 N e x t 
 
 L o g g i n g . W r i t e L i n e ( N o w   &   "   -   "   &   " S c r i p t   F i n i s h e d " ) 
 
 L o g g i n g . C l o s e 
 
 w s c r i p t . q u i t 