05 November 2008

VBS Script To Copy A File To A Remote Machine

From Myitforum
 
VBS Script To Copy A File To A Remote Machine
 

-------------------
Thanks,
http://paddymaddy.blogspot.com/

VBS Script To Copy A File To A Remote Machine

From Myitforum
 
VBS Script To Copy A File To A Remote Machine
 

-------------------
Thanks,
http://paddymaddy.blogspot.com/

Mof File for LowDisk Space Event ID based on NT Event during hardware inventory

 
 
 

//------------------------------- LowDisk Space Event ID ------------------------------------

#pragma namespace("\\\\.\\root\\cimv2")
[Union,
ViewSources{"Select * FROM Win32_NTLogEvent WHERE LogFile = 'System' AND EventCode = 2013"},
ViewSpaces{"\\\\.\\root\\cimv2"},
dynamic,provider("MS_VIEW_INSTANCE_PROVIDER")]

Class NTLogEvent
{
     [PropertySources("LogFile"), Key] string LogFile;
     [PropertySources("RecordNumber"), Key] UINT32 Recordnumber;
     [PropertySources("Message")] String Message;
     [PropertySources("TimeGenerated")] DateTime TimeGenerated;
};

//-------------------------- Reporting Class-----------------------------------
#pragma namespace("\\\\.\\root\\CIMV2\\SMS")

[SMS_Report(TRUE),
SMS_Group_Name("Installed Updates"),
SMS_Class_ID("MICROSOFT|Win32_NTLogEvent|1.0") ]

Class NTLogEvent: SMS_Class_Template
{
     [SMS_Report(TRUE), Key] String LogFile;
     [SMS_Report(TRUE), Key] UINT32 RecordNumber;
     [SMS_Report(True)] String Message;
     [SMS_Report(True)] DateTime TimeGenerated;
}; 


-------------------
Thanks,
http://paddymaddy.blogspot.com/

Mof File for LowDisk Space Event ID based on NT Event during hardware inventory

 
 
 

//------------------------------- LowDisk Space Event ID ------------------------------------

#pragma namespace("\\\\.\\root\\cimv2")
[Union,
ViewSources{"Select * FROM Win32_NTLogEvent WHERE LogFile = 'System' AND EventCode = 2013"},
ViewSpaces{"\\\\.\\root\\cimv2"},
dynamic,provider("MS_VIEW_INSTANCE_PROVIDER")]

Class NTLogEvent
{
     [PropertySources("LogFile"), Key] string LogFile;
     [PropertySources("RecordNumber"), Key] UINT32 Recordnumber;
     [PropertySources("Message")] String Message;
     [PropertySources("TimeGenerated")] DateTime TimeGenerated;
};

//-------------------------- Reporting Class-----------------------------------
#pragma namespace("\\\\.\\root\\CIMV2\\SMS")

[SMS_Report(TRUE),
SMS_Group_Name("Installed Updates"),
SMS_Class_ID("MICROSOFT|Win32_NTLogEvent|1.0") ]

Class NTLogEvent: SMS_Class_Template
{
     [SMS_Report(TRUE), Key] String LogFile;
     [SMS_Report(TRUE), Key] UINT32 RecordNumber;
     [SMS_Report(True)] String Message;
     [SMS_Report(True)] DateTime TimeGenerated;
}; 


-------------------
Thanks,
http://paddymaddy.blogspot.com/

SCCM 2007 Performance Questions whitepaper published

-------------------
Thanks,
http://paddymaddy.blogspot.com/

SCCM 2007 Performance Questions whitepaper published

-------------------
Thanks,
http://paddymaddy.blogspot.com/

Client is Installed Flag Explained


-------------------
Thanks,
http://paddymaddy.blogspot.com/

Client is Installed Flag Explained


-------------------
Thanks,
http://paddymaddy.blogspot.com/

03 November 2008

File and Print Enable

 

Set objFirewall = CreateObject("HNetCfg.FwMgr")
Set objPolicy = objFirewall.LocalPolicy.CurrentProfile

Set colServices = objPolicy.Services
Set objService = colServices.Item(0)
objService.Enabled = True

-------------------
Thanks,
http://paddymaddy.blogspot.com/

File and Print Enable

 

Set objFirewall = CreateObject("HNetCfg.FwMgr")
Set objPolicy = objFirewall.LocalPolicy.CurrentProfile

Set colServices = objPolicy.Services
Set objService = colServices.Item(0)
objService.Enabled = True

-------------------
Thanks,
http://paddymaddy.blogspot.com/

System Info OS and Service Pack Level

' **************************
' ServerInfo.vbs
' Collects OS and SP info
' List of systems must be in same directory as script
' Run using cscript
' **************************
' Name of Input File
strInputFile = "Syslist.txt"
' Name of Output File
strOutputFile = "ServerInfo.csv"

' Create file system object
set objFSO = CreateObject("Scripting.FileSystemObject")
' Check for Existing Output file, Create output file
If  objFSO.FileExists(strOutputFile) Then
   Wscript.echo "You must delete or remove " &  strOutputFile & " from this directory prior to running script"
   wscript.quit
End If
set objOutputFile = objFSO.OpenTextFile(strOutputFile, 2 , True)
If objFSO.FileExists(strInputFile) Then
  set objInStream = objFSO.OpenTextFile(strInputFile, 1)
' Begin reading input file
Set objWebmLocator = CreateObject("WbemScripting.SWbemLocator")
On Error Resume Next
Do While objInStream.AtEndOfStream <> True
 strComputer = objInStream.Readline
 'Wscript.echo ("Connecting to " & strComputer)
 Set objWMI = GetObject("winmgmts:" _
   & "{impersonationLevel=impersonate}!\\" _
   & strComputer & "\root\cimv2")
 
 If Err.number <> 0 Then
  Err.clear
  Set objWMI = objWebmLocator.ConnectServer(strComputer, "root\CIMV2", strUser, strPassword)
 End If
 If Err.Number <> 0 Then
  objOutputFile.Writeline(strComputer & ",Unavailable")
  'WScript.echo ("Connection Failed")
 Else
  Set colOS = objWMI.ExecQuery("Select Caption From Win32_OperatingSystem")
  Set colSP = objWMI.ExecQuery("Select CSDVersion From Win32_OperatingSystem")
 
  intOSCount = 0
  intSPCount = 0
 
  For Each objOS In colOS
   intOSCount = intOSCount + 1
   strOSVal = Replace(objOS.Caption, ",", " ")
  Next
  For Each objSP in colSP
   intSPCount = intSPCount + 1
   strSPVal = objSP.CSDVersion
  Next
  If intOSCount + intSpCOunt > 2 Then
   strVerified = "Unconfirmed"
  Else
   strVerified = "Confirmed"
  End If
  objOutputFile.Writeline(strComputer & "," & strOSVal & "," & strSPVal & "," & strVerified)

 End If
 Err.Clear
 
Loop
End IF
wscript.echo ("Script Complete")
wscript.quit

-------------------
Thanks,
http://paddymaddy.blogspot.com/

System Info OS and Service Pack Level

' **************************
' ServerInfo.vbs
' Collects OS and SP info
' List of systems must be in same directory as script
' Run using cscript
' **************************
' Name of Input File
strInputFile = "Syslist.txt"
' Name of Output File
strOutputFile = "ServerInfo.csv"

' Create file system object
set objFSO = CreateObject("Scripting.FileSystemObject")
' Check for Existing Output file, Create output file
If  objFSO.FileExists(strOutputFile) Then
   Wscript.echo "You must delete or remove " &  strOutputFile & " from this directory prior to running script"
   wscript.quit
End If
set objOutputFile = objFSO.OpenTextFile(strOutputFile, 2 , True)
If objFSO.FileExists(strInputFile) Then
  set objInStream = objFSO.OpenTextFile(strInputFile, 1)
' Begin reading input file
Set objWebmLocator = CreateObject("WbemScripting.SWbemLocator")
On Error Resume Next
Do While objInStream.AtEndOfStream <> True
 strComputer = objInStream.Readline
 'Wscript.echo ("Connecting to " & strComputer)
 Set objWMI = GetObject("winmgmts:" _
   & "{impersonationLevel=impersonate}!\\" _
   & strComputer & "\root\cimv2")
 
 If Err.number <> 0 Then
  Err.clear
  Set objWMI = objWebmLocator.ConnectServer(strComputer, "root\CIMV2", strUser, strPassword)
 End If
 If Err.Number <> 0 Then
  objOutputFile.Writeline(strComputer & ",Unavailable")
  'WScript.echo ("Connection Failed")
 Else
  Set colOS = objWMI.ExecQuery("Select Caption From Win32_OperatingSystem")
  Set colSP = objWMI.ExecQuery("Select CSDVersion From Win32_OperatingSystem")
 
  intOSCount = 0
  intSPCount = 0
 
  For Each objOS In colOS
   intOSCount = intOSCount + 1
   strOSVal = Replace(objOS.Caption, ",", " ")
  Next
  For Each objSP in colSP
   intSPCount = intSPCount + 1
   strSPVal = objSP.CSDVersion
  Next
  If intOSCount + intSpCOunt > 2 Then
   strVerified = "Unconfirmed"
  Else
   strVerified = "Confirmed"
  End If
  objOutputFile.Writeline(strComputer & "," & strOSVal & "," & strSPVal & "," & strVerified)

 End If
 Err.Clear
 
Loop
End IF
wscript.echo ("Script Complete")
wscript.quit

-------------------
Thanks,
http://paddymaddy.blogspot.com/

WMI Connectivity Check

Set objExcel = CreateObject("Excel.Application")

objExcel.Visible = True

objExcel.Workbooks.Add

intRow = 2

 

objExcel.Cells(1, 1).Value = "Machine Name"

objExcel.Cells(1, 2).Value = "Status"

objExcel.Cells(1, 3).Value = "Error Number"

objExcel.Cells(1, 4).Value = "Hex Error Number"

objExcel.Cells(1, 5).Value = "Error Description"

 

Set Fso = CreateObject("Scripting.FileSystemObject")

Set InputFile = fso.OpenTextFile("MachineList.Txt")

Do While Not (InputFile.atEndOfStream)

strComputer = InputFile.ReadLine

 

On Error Resume Next

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\Wmi")

objExcel.Cells(intRow, 1).Value = UCase(strComputer)

 

If Err.Number <> 0 Then

objExcel.Cells(intRow, 2).Value = "Error"

objExcel.Cells(intRow, 3).Value = Err.Number

objExcel.Cells(intRow, 4).Value = Hex(Err.Number)

ElseIf Err.Number = 0 Then

objExcel.Cells(intRow, 2).Value = "Success"

objExcel.Cells(intRow, 5).Value = "No Errors"

Err.Clear

End If

 

If Err.Number = 462 Then

objExcel.Cells(intRow, 5).Value = "Machine Not Found"

ElseIf Err.Number = "-2147217394" Then

objExcel.Cells(intRow, 5).Value = "WMI Class Not Found"

ElseIf Err.Number = "-2147217405" Then

objExcel.Cells(intRow, 5).Value = "Access Denied"

Err.Clear

End If

 

If objExcel.Cells(intRow, 2).Value = "Error" Then

objExcel.Cells(intRow, 2).Font.ColorIndex = 3

Else

objExcel.Cells(intRow, 2).Font.ColorIndex = 10

End If

 

intRow = intRow + 1

Loop

 

objExcel.Range("A1:E1").Select

objExcel.Selection.Interior.ColorIndex = 19

objExcel.Selection.Font.ColorIndex = 11

objExcel.Selection.Font.Bold = True

objExcel.Cells.EntireColumn.AutoFit

 

MsgBox "Done"


-------------------
Thanks,
http://paddymaddy.blogspot.com/

WMI Connectivity Check

Set objExcel = CreateObject("Excel.Application")

objExcel.Visible = True

objExcel.Workbooks.Add

intRow = 2

 

objExcel.Cells(1, 1).Value = "Machine Name"

objExcel.Cells(1, 2).Value = "Status"

objExcel.Cells(1, 3).Value = "Error Number"

objExcel.Cells(1, 4).Value = "Hex Error Number"

objExcel.Cells(1, 5).Value = "Error Description"

 

Set Fso = CreateObject("Scripting.FileSystemObject")

Set InputFile = fso.OpenTextFile("MachineList.Txt")

Do While Not (InputFile.atEndOfStream)

strComputer = InputFile.ReadLine

 

On Error Resume Next

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\Wmi")

objExcel.Cells(intRow, 1).Value = UCase(strComputer)

 

If Err.Number <> 0 Then

objExcel.Cells(intRow, 2).Value = "Error"

objExcel.Cells(intRow, 3).Value = Err.Number

objExcel.Cells(intRow, 4).Value = Hex(Err.Number)

ElseIf Err.Number = 0 Then

objExcel.Cells(intRow, 2).Value = "Success"

objExcel.Cells(intRow, 5).Value = "No Errors"

Err.Clear

End If

 

If Err.Number = 462 Then

objExcel.Cells(intRow, 5).Value = "Machine Not Found"

ElseIf Err.Number = "-2147217394" Then

objExcel.Cells(intRow, 5).Value = "WMI Class Not Found"

ElseIf Err.Number = "-2147217405" Then

objExcel.Cells(intRow, 5).Value = "Access Denied"

Err.Clear

End If

 

If objExcel.Cells(intRow, 2).Value = "Error" Then

objExcel.Cells(intRow, 2).Font.ColorIndex = 3

Else

objExcel.Cells(intRow, 2).Font.ColorIndex = 10

End If

 

intRow = intRow + 1

Loop

 

objExcel.Range("A1:E1").Select

objExcel.Selection.Interior.ColorIndex = 19

objExcel.Selection.Font.ColorIndex = 11

objExcel.Selection.Font.Bold = True

objExcel.Cells.EntireColumn.AutoFit

 

MsgBox "Done"


-------------------
Thanks,
http://paddymaddy.blogspot.com/

Admin$ check

Set objExcel = CreateObject("Excel.Application")

objExcel.Visible = True

objExcel.Workbooks.Add

intRow = 2

 

objExcel.Cells(1, 1).Value = "Machine Name"

objExcel.Cells(1, 2).Value = "Admin Share Exists"

 

Set Fso = CreateObject("Scripting.FileSystemObject")

Set InputFile = fso.OpenTextFile("MachineList.Txt")

Do While Not (InputFile.atEndOfStream)

strComputer = InputFile.ReadLine

 

On Error Resume Next

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colShares = objWMIService.ExecQuery("Select * from Win32_Share Where Name = 'ADMIN$'")

 

objExcel.Cells(intRow, 1).Value = UCase(strComputer)

If colShares.Count > 0 Then

objExcel.Cells(intRow, 2).Value = "Yes"

Else

objExcel.Cells(intRow, 2).Value = "No"

End If

If Err.Number <> 0 Then

objExcel.Cells(intRow, 2).Value = Err.Description

Err.Clear

End If

intRow = intRow + 1

 

objExcel.Range("A1:B1").Select

objExcel.Selection.Interior.ColorIndex = 19

objExcel.Selection.Font.ColorIndex = 11

objExcel.Selection.Font.Bold = True

objExcel.Cells.EntireColumn.AutoFit

loop

 

Wscript.Echo "Done"


-------------------
Thanks,
http://paddymaddy.blogspot.com/

Admin$ check

Set objExcel = CreateObject("Excel.Application")

objExcel.Visible = True

objExcel.Workbooks.Add

intRow = 2

 

objExcel.Cells(1, 1).Value = "Machine Name"

objExcel.Cells(1, 2).Value = "Admin Share Exists"

 

Set Fso = CreateObject("Scripting.FileSystemObject")

Set InputFile = fso.OpenTextFile("MachineList.Txt")

Do While Not (InputFile.atEndOfStream)

strComputer = InputFile.ReadLine

 

On Error Resume Next

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colShares = objWMIService.ExecQuery("Select * from Win32_Share Where Name = 'ADMIN$'")

 

objExcel.Cells(intRow, 1).Value = UCase(strComputer)

If colShares.Count > 0 Then

objExcel.Cells(intRow, 2).Value = "Yes"

Else

objExcel.Cells(intRow, 2).Value = "No"

End If

If Err.Number <> 0 Then

objExcel.Cells(intRow, 2).Value = Err.Description

Err.Clear

End If

intRow = intRow + 1

 

objExcel.Range("A1:B1").Select

objExcel.Selection.Interior.ColorIndex = 19

objExcel.Selection.Font.ColorIndex = 11

objExcel.Selection.Font.Bold = True

objExcel.Cells.EntireColumn.AutoFit

loop

 

Wscript.Echo "Done"


-------------------
Thanks,
http://paddymaddy.blogspot.com/

Remote Systems Discovery Data Collection Cycle Client agent initiate

On Error Resume Next
Dim oCPAppletMgr
Set oCPAppletMgr = CreateObject("CPApplet.CPAppletMgr")
Dim oClientActions
Set oClientActions = oCPAppletMgr.GetClientActions()
Dim oClientAction
For Each oClientAction In oClientActions
If oClientAction.Name = "Discovery Data Collection Cycle" Then
oClientAction.PerformAction
End If
If oClientAction.Name = "Request & Evaluate Machine Policy" Then
oClientAction.PerformAction
End If
Next

-------------------
Thanks,
http://paddymaddy.blogspot.com/

Remote Systems Discovery Data Collection Cycle Client agent initiate

On Error Resume Next
Dim oCPAppletMgr
Set oCPAppletMgr = CreateObject("CPApplet.CPAppletMgr")
Dim oClientActions
Set oClientActions = oCPAppletMgr.GetClientActions()
Dim oClientAction
For Each oClientAction In oClientActions
If oClientAction.Name = "Discovery Data Collection Cycle" Then
oClientAction.PerformAction
End If
If oClientAction.Name = "Request & Evaluate Machine Policy" Then
oClientAction.PerformAction
End If
Next

-------------------
Thanks,
http://paddymaddy.blogspot.com/