Microsoft intendeva aggiungere una nuova interfaccia ed un nuovo linguaggio di scripting da riga di comando (nome in codice "Monad") a Vista ma ha deciso di creare un'utilità standalone chiamata Windows PowerShell 1.0. E' uno strumento disegnato principalmente per amministratori di sistema, ma è in grado di dare benefici anche a utenti di rete casalingi e di piccoli uffici che utilizzano le versioni Professional di Windows. Un utente può installare PowerShell su Windows XP, Windows Server 2003, e Windows Vista.
Invece di essere composto da un insieme di singoli comandi, Windows PowerShell è composto da programmi object-oriented chiamati cmdlets (si pronuncia "command lets"), che possono essere eseguiti solo all'interno dell'interfaccia di PowerShell. I cmdlets eseguono una singola operazione per volta e sono disegnati per lavorare insieme per eseguire operazioni più complesse.
Per poter utilizzare Windows PowerShell sulla tua macchina con Windows XP Pro, devi scaricarlo e installarlo. Ecco come fare:
1. Vai sulla pagina di download di Windows PowerShell 1.0
2. Scarica e installa .NET Framework 2.0 se non è già installato sulla tua macchina
3. Dopo aver installato il .NET Framework 2.0, scarica e installa il Windows XP Service Pack 2 -- versione Windows PowerShell 1.0 che vada bene per la tua piattaforma (x86 o x64).
Una volta installato Windows PowerShell, via sul sito "Scripting with Windows PowerShell" e guarda alcuni esempi di utilizzo nella sezione Getting Started. Se vuoi vedere ulteriori esempi di utilizzo guarda lo Script Center Script Repository.
Visualizzazione post con etichetta Script. Mostra tutti i post
Visualizzazione post con etichetta Script. Mostra tutti i post
Rilevazione software installato su PC
Utilizzando questo script come script di logon, verrrà creato un file xls NOMEUTENTE_NOMEPC con tutti i software installati nella macchina locale. Vi potrà essere molto utile per fare un censimento del SW utilizzato sui client della vostra LAN.
Set objFSO = CreateObject("Scripting.FileSystemObject")
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSoftware = objWMIService.ExecQuery _
("Select UserName,Caption from Win32_ComputerSystem")
dim nomeUtente
For Each objSoftware in colSoftware
nomeUtente = objSoftware.UserName
nomeMacchina = objSoftware.Caption
next
dim dominio
dim shareFOlder
'******Init Config****************
dominio = "NOME_DOMINIO"
shareFolder = "\\NOME_PC\PUBLIC SHARE\"
'******End Config********************
if not IsNull(nomeUtente) then
nomeUtente = replace(nomeUtente,dominio & "\","")
dim pathFile
pathFile = shareFolder & nomeUtente & nomeMacchina & ".xls"
Dim fso, msg
Set fso = CreateObject("Scripting.FileSystemObject")
If not fso.FileExists(pathFile) Then
Set objTextFile = objFSO.CreateTextFile(pathfile, True)
objTextFile.WriteLine nomeMacchina & vbtab & nomeUtente & vbCrLf
Set colSoftware = objWMIService.ExecQuery("Select Caption,Vendor,Version from Win32_Product")
objTextFile.WriteLine "Caption" & vbtab & "Vendor" & vbtab & "Version"
For Each objSoftware in colSoftware
objTextFile.WriteLine objSoftware.Caption & vbtab & _
objSoftware.Vendor & vbtab & _
objSoftware.Version
Next
objTextFile.Close
End If
set fso = Nothing
End If
Set objFSO = CreateObject("Scripting.FileSystemObject")
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSoftware = objWMIService.ExecQuery _
("Select UserName,Caption from Win32_ComputerSystem")
dim nomeUtente
For Each objSoftware in colSoftware
nomeUtente = objSoftware.UserName
nomeMacchina = objSoftware.Caption
next
dim dominio
dim shareFOlder
'******Init Config****************
dominio = "NOME_DOMINIO"
shareFolder = "\\NOME_PC\PUBLIC SHARE\"
'******End Config********************
if not IsNull(nomeUtente) then
nomeUtente = replace(nomeUtente,dominio & "\","")
dim pathFile
pathFile = shareFolder & nomeUtente & nomeMacchina & ".xls"
Dim fso, msg
Set fso = CreateObject("Scripting.FileSystemObject")
If not fso.FileExists(pathFile) Then
Set objTextFile = objFSO.CreateTextFile(pathfile, True)
objTextFile.WriteLine nomeMacchina & vbtab & nomeUtente & vbCrLf
Set colSoftware = objWMIService.ExecQuery("Select Caption,Vendor,Version from Win32_Product")
objTextFile.WriteLine "Caption" & vbtab & "Vendor" & vbtab & "Version"
For Each objSoftware in colSoftware
objTextFile.WriteLine objSoftware.Caption & vbtab & _
objSoftware.Vendor & vbtab & _
objSoftware.Version
Next
objTextFile.Close
End If
set fso = Nothing
End If
Ottenere le informazioni di un PC
Con questo script potrete ottenere alcune informazioni (CPU, Hard Disk, Processore) di un PC.
Set objFSO = CreateObject("Scripting.FileSystemObject")
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSoftware = objWMIService.ExecQuery ("Select UserName,Caption from Win32_ComputerSystem")
For Each objSoftware in colSoftware
nomeUtente = objSoftware.UserName
nomeMacchina = objSoftware.Caption
next
dim dominio
dim shareFOlder
'******Init Config****************
dominio = "NOME-DOMINIO"
shareFolder = "\\MIO_PC\PUBLIC SHARE\"
'******End Config********************
if not IsNull(nomeUtente) then
nomeUtente = replace(nomeUtente,dominio & "\","")
dim pathFile
pathFile = shareFolder & nomeUtente & nomeMacchina & ".xls"
Dim fso, msg
Set fso = CreateObject("Scripting.FileSystemObject")
If not fso.FileExists(pathFile) Then
'processor informations
Set colSoftware = objWMIService.ExecQuery("Select Manufacturer,Name from Win32_processor")
For Each objSoftware in colSoftware
procManuf = objSoftware.Manufacturer
procName = objSoftware.Name
Next
'Computer Informations
Set colSoftware = objWMIService.ExecQuery("Select Model,Manufacturer from Win32_ComputerSystem")
For Each objSoftware in colSoftware
pcModel = objSoftware.Model
pcManuf = objSoftware.Manufacturer
Next
'HDD Informations
Set colSoftware = objWMIService.ExecQuery("Select Size from Win32_LogicalDisk where caption = 'C:'")
For Each objSoftware in colSoftware
hddSize = objSoftware.Size
'hddVolName = objSoftware.VolumeName
Next
'scrivo il file
Set objTextFile = objFSO.CreateTextFile(pathfile, True)
objTextFile.WriteLine nomeMacchina & vbtab & nomeUtente & vbCrLf
'preparo intestazione file
objTextFile.WriteLine "Processore" & vbtab & "Nome Processore" & vbtab & "Modello PC" & vbtab & "Manufacturer" & vbtab & "HDD Size" & vbCrLf
objTextFile.WriteLine procManuf & vbtab & procName & vbtab & pcModel & vbtab & pcManuf & vbtab & hddSize
objTextFile.Close
End If
set fso = Nothing
end if
Set objFSO = CreateObject("Scripting.FileSystemObject")
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSoftware = objWMIService.ExecQuery ("Select UserName,Caption from Win32_ComputerSystem")
For Each objSoftware in colSoftware
nomeUtente = objSoftware.UserName
nomeMacchina = objSoftware.Caption
next
dim dominio
dim shareFOlder
'******Init Config****************
dominio = "NOME-DOMINIO"
shareFolder = "\\MIO_PC\PUBLIC SHARE\"
'******End Config********************
if not IsNull(nomeUtente) then
nomeUtente = replace(nomeUtente,dominio & "\","")
dim pathFile
pathFile = shareFolder & nomeUtente & nomeMacchina & ".xls"
Dim fso, msg
Set fso = CreateObject("Scripting.FileSystemObject")
If not fso.FileExists(pathFile) Then
'processor informations
Set colSoftware = objWMIService.ExecQuery("Select Manufacturer,Name from Win32_processor")
For Each objSoftware in colSoftware
procManuf = objSoftware.Manufacturer
procName = objSoftware.Name
Next
'Computer Informations
Set colSoftware = objWMIService.ExecQuery("Select Model,Manufacturer from Win32_ComputerSystem")
For Each objSoftware in colSoftware
pcModel = objSoftware.Model
pcManuf = objSoftware.Manufacturer
Next
'HDD Informations
Set colSoftware = objWMIService.ExecQuery("Select Size from Win32_LogicalDisk where caption = 'C:'")
For Each objSoftware in colSoftware
hddSize = objSoftware.Size
'hddVolName = objSoftware.VolumeName
Next
'scrivo il file
Set objTextFile = objFSO.CreateTextFile(pathfile, True)
objTextFile.WriteLine nomeMacchina & vbtab & nomeUtente & vbCrLf
'preparo intestazione file
objTextFile.WriteLine "Processore" & vbtab & "Nome Processore" & vbtab & "Modello PC" & vbtab & "Manufacturer" & vbtab & "HDD Size" & vbCrLf
objTextFile.WriteLine procManuf & vbtab & procName & vbtab & pcModel & vbtab & pcManuf & vbtab & hddSize
objTextFile.Close
End If
set fso = Nothing
end if
Script per salvare in file xls la lista dei software installati
Utilizzando questo script come script di logon, verrrà creato un file xls NOMEUTENTE_NOMEPC con tutti i software installati nella macchina locale. Vi potrà essere molto utile per fare un censimento del SW utilizzato sui client della vostra LAN.
Set objFSO = CreateObject("Scripting.FileSystemObject")
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSoftware = objWMIService.ExecQuery _
("Select UserName,Caption from Win32_ComputerSystem")
dim nomeUtente
For Each objSoftware in colSoftware
nomeUtente = objSoftware.UserName
nomeMacchina = objSoftware.Caption
next
dim dominio
dim shareFOlder
'******Init Config****************
dominio = "NOME_DOMINIO"
shareFolder = "\\NOME_PC\PUBLIC SHARE\"
'******End Config********************
if not IsNull(nomeUtente) then
nomeUtente = replace(nomeUtente,dominio & "\","")
dim pathFile
pathFile = shareFolder & nomeUtente & nomeMacchina & ".xls"
Dim fso, msg
Set fso = CreateObject("Scripting.FileSystemObject")
If not fso.FileExists(pathFile) Then
Set objTextFile = objFSO.CreateTextFile(pathfile, True)
objTextFile.WriteLine nomeMacchina & vbtab & nomeUtente & vbCrLf
Set colSoftware = objWMIService.ExecQuery("Select Caption,Vendor,Version from Win32_Product")
objTextFile.WriteLine "Caption" & vbtab & "Vendor" & vbtab & "Version"
For Each objSoftware in colSoftware
objTextFile.WriteLine objSoftware.Caption & vbtab & _
objSoftware.Vendor & vbtab & _
objSoftware.Version
Next
objTextFile.Close
End If
set fso = Nothing
End If
Set objFSO = CreateObject("Scripting.FileSystemObject")
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSoftware = objWMIService.ExecQuery _
("Select UserName,Caption from Win32_ComputerSystem")
dim nomeUtente
For Each objSoftware in colSoftware
nomeUtente = objSoftware.UserName
nomeMacchina = objSoftware.Caption
next
dim dominio
dim shareFOlder
'******Init Config****************
dominio = "NOME_DOMINIO"
shareFolder = "\\NOME_PC\PUBLIC SHARE\"
'******End Config********************
if not IsNull(nomeUtente) then
nomeUtente = replace(nomeUtente,dominio & "\","")
dim pathFile
pathFile = shareFolder & nomeUtente & nomeMacchina & ".xls"
Dim fso, msg
Set fso = CreateObject("Scripting.FileSystemObject")
If not fso.FileExists(pathFile) Then
Set objTextFile = objFSO.CreateTextFile(pathfile, True)
objTextFile.WriteLine nomeMacchina & vbtab & nomeUtente & vbCrLf
Set colSoftware = objWMIService.ExecQuery("Select Caption,Vendor,Version from Win32_Product")
objTextFile.WriteLine "Caption" & vbtab & "Vendor" & vbtab & "Version"
For Each objSoftware in colSoftware
objTextFile.WriteLine objSoftware.Caption & vbtab & _
objSoftware.Vendor & vbtab & _
objSoftware.Version
Next
objTextFile.Close
End If
set fso = Nothing
End If
Aggiornare una zona DNS
Questo script vi permetterà di aggiornare la vostra zona DNS.
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\MicrosoftDNS")
Set colItems = objWMIService.ExecQuery _
("Select * from MicrosoftDNS_Zone Where Name = 'zona_dns_da_aggiornare'")
For Each objItem in colItems
objItem.UpdateFromDS()
Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\MicrosoftDNS")
Set colItems = objWMIService.ExecQuery _
("Select * from MicrosoftDNS_Zone Where Name = 'zona_dns_da_aggiornare'")
For Each objItem in colItems
objItem.UpdateFromDS()
Next
Iscriviti a:
Post (Atom)