VBS --> PowerShell ???

Author Message
^Ii^

  • Total Posts : 10
  • Scores: 0
  • Reward points : 0
  • Joined: 8/12/2010
  • Status: offline
VBS --> PowerShell ??? Monday, September 06, 2010 9:58 PM (permalink)
0
don't work on win7

' script write in computer description in AD name of logined user
 Set objSysInfo = CreateObject("ADSystemInfo") 
 Set objComputer = GetObject("LDAP://" & objSysInfo.ComputerName) 
 k = 34 
 kk = Chr(k) 
 Set WshShell = WScript.CreateObject ("WScript.Shell") 
 IF  WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\CurrentVersion") > "5.1" Then 
     objDefaultUserName =WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\LastLoggedOnUser") 
     LenDUN = InStr(objDefaultUserName,"\")
     objDefaultUserName = Right(objDefaultUserName,LenDUN) 
 Else 
     objDefaultUserName =WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultUserName") 
 End If
 Set net = WshShell.Exec ("net config server /srvcomment:" & kk & objDefaultUserName & " " &  objComputer.location & kk) 
 objComputer.Description = WSHShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters\srvcomment")
 objComputer.SetInfo 

 
#1
    ebgreen

    • Total Posts : 8227
    • Scores: 98
    • Reward points : 0
    • Joined: 7/12/2005
    • Status: offline
    Re:VBS --> PowerShell ??? Tuesday, September 07, 2010 2:03 AM (permalink)
    0
    So do you want to convert it to powershell, or do you want to get the VBS to work in W7? VBScripts run just fine in W7.
    "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
    Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
    http://www.visualbasicscript.com/m_47117/tm.htm
     
    #2
      ^Ii^

      • Total Posts : 10
      • Scores: 0
      • Reward points : 0
      • Joined: 8/12/2010
      • Status: offline
      Re:VBS --> PowerShell ??? Tuesday, September 07, 2010 2:13 AM (permalink)
      0
      i want all))) but primary convert
       
      #3
        TomRiddle

        • Total Posts : 620
        • Scores: 12
        • Reward points : 0
        • Joined: 2/7/2008
        • Location: Australia
        • Status: offline
        Re:VBS --> PowerShell ??? Thursday, September 16, 2010 2:25 PM (permalink)
        0
        Check out the Microsoft VBScript to PowerShell conversion guide
        http://technet.microsoft.com/en-us/library/ee221101.aspx

        If you just want to write last logged on user name to registry then I would re write it completely.
        Also looks like you might have to find the W7 equivalent for:
        net config server /srvcomment:"XXX"
        http://support.microsoft.com/kb/556004/en-us

        -join([int[]][char[]]'Ut|jwXmjqq%Wzqjx'|%{[char]($_-5)})
         
        #4
          ^Ii^

          • Total Posts : 10
          • Scores: 0
          • Reward points : 0
          • Joined: 8/12/2010
          • Status: offline
          Re:VBS --> PowerShell ??? Wednesday, September 29, 2010 7:04 PM (permalink)
          0
           $dom = 'LDAP://DC=***;DC=***'
           $filter = "(SamAccountName=$env:computername$)"
           $root = new-object directoryservices.directoryentry $dom
           $searcher = new-object directoryservices.directorysearcher
           $searcher.searchroot = $root
           $searcher.filter = $filter
           $searcher.searchScope = "subtree"
           $searcher.propertiesToLoad.add("Location")
           $comp = $searcher.findOne()
           $compLoc = $comp.Properties.location
           $pathComp = $comp.path
           "'" + $pathComp + "'"
           
           $Registry_Key = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI"
           [Microsoft.Win32.RegistryKey]$username = get-item $Registry_Key
           foreach ($p in $username)
           {
               foreach ($key in $p.getvalueNames())
               {
                   if ($key = "LastLoggedOnUser")
                   {
                       $keyname2 = $p.GetValue($key)
                   }
               }
           }
           $keyname = $keyname2 -split "\\",2
           $keyname = $keyname[1]
           
           $comp = gwmi win32_operatingsystem
           $comp.description = "$keyname $compLoc" 
           $comp.put()
           
           
           $adAccount = [ADSI]$pathComp
           Write-Host $adAccount.Get(“Description”)
           $adAccount.Put(“Description”,"$keyName $compLoc")
           $adAccount.SetInfo()
           

          that's all))
           
          #5
            anytua34i

            • Total Posts : 9
            • Scores: 0
            • Reward points : 0
            • Joined: 1/24/2011
            • Status: offline
            Re:VBS --> PowerShell ??? Monday, January 24, 2011 7:04 PM (permalink)
            0
            When the 10 morning arrived San Jose Asian Escort the Druids would give San Jose Asian Escorts a piece of wood San Jose Escort from their fires to each family,then they would take them home to start new cooking fires.These San Jose Escorts fires would keep the homes warm and free from evil
             
            #6

              Online Bookmarks Sharing: Share/Bookmark

              Jump to:

              Current active users

              There are 0 members and 1 guests.

              Icon Legend and Permission

              • New Messages
              • No New Messages
              • Hot Topic w/ New Messages
              • Hot Topic w/o New Messages
              • Locked w/ New Messages
              • Locked w/o New Messages
              • Read Message
              • Post New Thread
              • Reply to message
              • Post New Poll
              • Submit Vote
              • Post reward post
              • Delete my own posts
              • Delete my own threads
              • Rate post

              2000-2012 ASPPlayground.NET Forum Version 3.9