Tuesday, April 10, 2012

VBS Script to Verify If The Admin$ Share Exists On A List Of Machines

Before deploying SCCM Client to the client machine we need to confirm if Admin$ Share Exists. Instead of doing the same manually, we have created the script which you can use to test if the share exists on client machine or not. Hope it helps to automate your process!!!!

Create a text file created with the Computer Names.


Below is the script for checking AdminShare$ on client systems in the environment.


 Actual Script:-

Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Add
intRow = 2
objExcel.Cells(1, 1).Value = "Computer Name"
objExcel.Cells(1, 2).Value = "Admin Share Exists" 
Set Fso = CreateObject("Scripting.FileSystemObject")
Set InputFile = fso.OpenTextFile("ComputerList.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"
To Run the script:
               1. Open cmd as administrator
               2. Go to the vbs file location
               3. Run the script as below


 It will give the successful prompt “Done” as shown below.


 Below is the excel sheet with the result.


When you have the result then you can suitably go ahead with the SCCM Client deployment.

2 comments:

  1. Thanks for sharing your info. I really appreciate your efforts and I will be waiting for your further write ups thanks once again.

    ReplyDelete
  2. Thanks a lot I have the same issue and was looking for this!! thanks!

    ReplyDelete

Azure Policy support for remediating tags for existing resources

Use Azure policy to remediate tags for existing resources. https://azure.microsoft.com/en-us/updates/azure-provides-at-scale-tags-managem...