Video Screencast Help
Symantec to Separate Into Two Focused, Industry-Leading Technology Companies. Learn more.

DS 7.x Task to Collect Debugging Logs from Automation to SMP

Created: 12 Dec 2012 • Updated: 06 Jul 2013 | 6 comments
Language Translations
Thomas Baird's picture
+2 2 Votes
Login to vote

Below is a VBScript that can be used to collect logs from Automation to the SMP (Under NSCap by default) for review in case of imaging issues.  It will work with both DS 7.1 and DS 7.5

To create the task:

  1. In the SMP Console, select Manage | Jobs and Tasks
  2. Right-click on Samples\Deployment Solution (or another folder of your choice) and choose New\Task
  3. Scroll to the bottom of the list, or nearly so, and select a Script Task.
  4. On the right, select VBScript from the drop list by Script Type.
  5. Copy the text from the table below and paste it into the empty text box below the drop box.  Do NOT make any changes under Advanced.
  6. Select Save
  7. Read the text at the top of the task.  There are a few things that you should modify for your own environment and comments for how to do so are provided in the task text:
  • AdminAcct
  • AdminPwd
  • Prod
  • LogsFolder - this one is where we will create a folder in NSCap to store the files
  • (optional) storage location.  This is not exposed in the top section but is later during the drive mapping.  If you would prefer NOT to save these logs in NSCap, obviously, this can be modified.  This is however the easiest location to find files during troubleshooting, and the files are not, in general, large enough to cause problems even over WAN links.

There are two tokens the task calls on that are important:

  • NSServer.  I believe that, depending on the version of the product you have, this token name may change.  Be sure the token is correct.
  • NOW.  This is an identifier for the time stamp on the created folder so you can run it again and again (one minute apart).  It will have to be created.  The name of the token is NOW, and the script is Select Convert(varchar(26), GetDate(), 109)

The task is complete and ready to be run.

Task Text:

Dim fso, f, WshShell, WshNetwork, oDrives, vMap, LogsFolder, NewFolder, Prod, Destination, AdminAcct, AdminPwd

'---------------------------------------------------
'
' Below are some variables you need to be aware of and customize before running this script
'
'---------------------------------------------------
AdminAcct = "YourAccount"     'Must have rights to map a drive back to NSCap
AdminPwd = "YourPassword"     'Associated password to the above account
' Prod may need to be changed to D or whatever your production drive is while in automation
' or run GHConfig which I don't yet know how to do here.
' Most Win7 Systems have a recovery partition, so Prod would be D: instead of C
Prod = "c:"
LogsFolder = "z:\AutomationLogs"    'Folder under NSCap to store the logs on the NS/SMP
'---------------------------------------------------
' End Customizations Section
'---------------------------------------------------

NewFolder = "%COMPNAME%_" & Replace("%NOW%",":",".")
Destination = LogsFolder & "\" & NewFolder
Set fso = CreateObject("Scripting.FileSystemObject")
Set WshNetwork = WScript.CreateObject("WScript.Network")

vMap = "Yes"
Set oDrives = WshNetwork.EnumNetworkDrives
  For i = 0 to oDrives.Count - 1 Step 2
    IF oDrives.Item(i) = "z:" THEN vMap = "No"
  Next
IF vMap = "Yes" THEN WshNetwork.MapNetworkDrive "z:", "\\%NSSERVER%\NSCap", ,AdminAcct ,AdminPwd

If (fso.FolderExists(LogsFolder)) Then
  Else
    fso.CreateFolder(LogsFolder)
  End If
fso.CreateFolder(Destination)

On Error Resume Next
fso.Copyfolder Prod & "\Windows\Panther", Destination & "\Panther"                'MiniSetup or SOI troubleshooting
fso.copyfolder "x:\Program Files\Altiris\Altiris Agent\Logs", Destination         'for DS 7.1
fso.copyfolder "x:\Program Files\Symantec\Deployment\Logs", Destination & "\Logs" 'for DS 7.5
fso.copyfile "x:\ghosterr.txt", Destination & "\"                                 'Ghost troubleshooting

WshNetwork.RemoveNetworkDrive "Z:"

 

 

Comments 6 CommentsJump to latest comment

Thomas Baird's picture

I had to make a few fixes to the article after testing in a few "new" environments.  Hope it helps.  I changed the NS server token, added a note about a possible known issue I need feedback on, and included the SQL for one of the tokens.

Thomas Baird
Enthusiast for making things better!

 

0
Login to vote
jobby's picture

Thomas,
I am unable to see the entire code field in the above task, so I'm unable to copy the text to copy it since it flows off the right side of the text box. Not a big deal at the moment. This looks very useful for an issue that we're currently having with one of our site servers.

0
Login to vote
Thomas Baird's picture

were you able to make this work?  I did not see your post - terribly sorry.  The text actually wraps when I look at it.  If you're not seeing it wrap, maybe try a different browser - like IE?  Maybe the community has some limitations for browser support.  Again, on my screen, it wraps.

Thomas Baird
Enthusiast for making things better!

 

0
Login to vote
jobby's picture

Haven't had a chance to try it anyway.  Ended up viewing it in Firefox, and it does wrap.  In IE 10, it doesn't wrap.  Thanks for checking back.

0
Login to vote
rjones's picture

I found that the NOW token (that I had to create in NS) returned a value that could not be used to create the destination folder (even using the Replace command). Therefore, I added a couple of variables (FullDate and MyDate) to collect and use the time stamp using VBScript's NOW command instead of creating a NOW token in NS.

I tested this in both DS 7.1 and DS 7.5 and it worked for me.

The modified script is as follows (the changes to the original script have been highlighted):

Dim fso, f, WshShell, WshNetwork, oDrives, vMap, LogsFolder, NewFolder, Prod, Destination, AdminAcct, AdminPwd, FullDate, MyDate

'---------------------------------------------------
'
' Below are some variables you need to be aware of and customize before running this script
'
'---------------------------------------------------

AdminAcct = "YourAccount such as Example\Admin"     'Must have rights to map a drive back to NSCap
AdminPwd = "YourPassword"     'Associated password to the above account
 

' Prod may need to be changed to D or whatever your production drive is while in automation
' or run GHConfig which I don't yet know how to do here.
' Most Win7 Systems have a recovery partition, so Prod would be D: instead of C

Prod = "C:"
LogsFolder = "z:\AutomationLogs"    'Folder under NSCap to store the logs on the NS/SMP
'---------------------------------------------------
' End Customizations Section
'---------------------------------------------------

FullDate=NOW
 

MyDate=Right("0" & Month(FullDate),2) & Right("0" & Day(FullDate),2) & Year(FullDate) & "_" & Right("0" & Hour(FullDate),2) & Right("0" & Minute(FullDate),2)

'The above line, adds a zero to each part of the date, but then only uses the right two numbers.

'This ensures that each field such as the Month Day will always have two numbers.

NewFolder = "%COMPNAME%_" & MyDate
Destination = LogsFolder & "\" & NewFolder
Set fso = CreateObject("Scripting.FileSystemObject")
Set WshNetwork = WScript.CreateObject("WScript.Network")

vMap = "Yes"
Set oDrives = WshNetwork.EnumNetworkDrives
  For i = 0 to oDrives.Count - 1 Step 2
    IF oDrives.Item(i) = "Z:" THEN vMap = "No"
  Next
IF vMap = "Yes" THEN WshNetwork.MapNetworkDrive "z:", "\\%NSSERVER%\NSCap", ,AdminAcct ,AdminPwd

If (fso.FolderExists(LogsFolder)) Then
  Else
    fso.CreateFolder(LogsFolder)
  End If
fso.CreateFolder(Destination)

On Error Resume Next
fso.Copyfolder Prod & "\Windows\Panther", Destination & "\Panther"                'MiniSetup or SOI troubleshooting
fso.copyfolder "x:\Program Files\Altiris\Altiris Agent\Logs", Destination         'for DS 7.1
fso.copyfolder "x:\Program Files\Symantec\Deployment\Logs", Destination & "\Logs"   'for DS 7.5
fso.copyfile "x:\ghosterr.txt", Destination                                       'Ghost troubleshooting

0
Login to vote
Thomas Baird's picture

OK - I finally got around to cleaning this up.

Depending on SQL colation and settings, the NOW function wasn't working (see the comment above), so I've updated it to be a bit more picky and safe, instead of assuming everyone would have the same "default" in SQL.  The new SELECT is easier to use, or you can follow the comments above.

The drive mapping thing is really weird.  I've found that if you have Z mapped, this task fails, but if not, works like a champ, so I've taken to removing the mapping at the end.  I'm still working on why having it mapped fails.

I also found out that the copyfile line was failing, because it lacked a final \ in the destination.  That's now fixed.

NOTE:  I'm also working on collecting the DA logs that are created, but that's a bit trickier.

Thomas Baird
Enthusiast for making things better!

 

0
Login to vote