domenica 18 novembre 2018

Centralino IP PBX su Windows - 3CX Phone System which links here: http://www.3cx.it/centralino/index.html

 

 

RSS Feed RSS Feed

Login

Newsletter Newsletter

Registrati

RisorseGuide e Articoli

 

31

Questo script vi consentirà di capire se i PC della vostra LAN sono desktop o portatili. Utile per riorganizzare le Organizational Unit di Active Directory.
 

Utilizzo:

ComputerType.vbs

Sintassi: 1 - cscript ComputerType.vbs
Sintassi: 2 - cscript ComputerType.vbs [ computer_name ]
Sintassi: 3 - cscript ComputerType.vbs @ drive:\Filename.extension

file di output : c:\out.txt

sorgente:

Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20

'controllo parametri di input
Select Case WScript.Arguments.Count
    Case 0
        ' Se 0 prendo il pc locale
        Set objWMIService = GetObject( "winmgmts://./root/cimv2" )
        Set colItems = objWMIService.ExecQuery( "Select * from Win32_ComputerSystem", , 48 )
        For Each objItem in colItems
            elencoComputer = objItem.Name
        Next
    Case 1
        'O nome DNS computer oppure il ? per l'help
        elencoComputer = Wscript.Arguments(0)
            if InStr( elencoComputer, "?" ) > 0 Then Syntax
    Case Else
        ' Input da file
        if wscript.arguments(0) = "@" then
            strFilePath = wscript.arguments(1)
            Set objFSO = CreateObject("Scripting.FileSystemObject")
            Set objFile = objFSO.OpenTextFile(strFilePath, 1)
            'leggo elenco di computer dal file
            Do Until objFile.AtEndOfStream
              elencoComputer = Trim(objFile.ReadLine)
              If elencoComputer<> "" Then
                On Error Resume Next
                Err.Clear
              End if
            Loop
        else
            Syntax
        end if

End Select

'Help syntax
Sub Syntax
    strMsg = vbCrLf & "ComputerType.vbs" & vbCrLf & _
             "Determina se un Computer � un Desktop o un Portatile." & vbCrLf & _
             vbCrLf & _
             "Sintassi:  1 - cscript ComputerType.vbs" & _
             vbCrLf & _
             "Sintassi:  2 - cscript ComputerType.vbs [ computer_name ]" & _
             vbCrLf & _
             "Sintassi:  3 - cscript ComputerType.vbs @ drive:\Filename.extension" & _
             vbCrLf & vbCrLf
    WScript.Echo strMsg
    WScript.Quit(1)
End Sub


'split dei nomi host in un array
arrComputers = split(elencoComputer,";")

'creo il file di output
pathfile="c:\out.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.CreateTextFile(pathfile, True)

For Each strComputer In arrComputers
   
   Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")

      Set colItems = objWMIService.ExecQuery("SELECT Description FROM Win32_Battery", "WQL",wbemFlagReturnImmediately + wbemFlagForwardOnly)
      descr = "Desktop"
      For Each objItem In colItems
        if LEN(objItem.Description) <> 0 then descr = "Portatile"   
      Next
      objTextFile.WriteLine strComputer & vbtab & descr & vbCrLf
Next

wscript.echo "Finished"
'chiudo il file
objTextFile.Close
set fso = Nothing


Scritto in: Script
AZIONI: E-mail | Permalink |
CONDIVIDI: del.icio.us   Facebook   Digg   Google   Live Bookmarks   Newsvine   StumbleUpon   Technorati   Yahoo   DotNetKicks
blog comments powered by Disqus

Copyright 2011 by SysAdmin.it