Eswar Koneti's Blog

All about Configmgr and its connected objects…….

  • About Author
      View eswar koneti's LinkedIn profile
  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 106 other subscribers

  • Awards


  • FaceBook Updates

  • Catagories

  • Meta

  • Copyright!

    All the blog posts in this website are owned by Eswar Koneti and may not be reused in any mode without prior approval of Eswar Koneti. You may quote one paragraph from the blog posts if you link to the original blog post.
    Happy Reading!

Archive for the 'Scripting' Category

Script to Download all MMS 2013 SCCM Configmgr 2012 Sessions

Posted by Eswar Koneti on 10th April 2013

Do you remember the Powershell script posted by SCOMFAQ  to download required MMS 2012 Sessions last year

Once again he come up with easy way to download all the required MMS 2013 sessions using Powershell script.

This basically contains 2 power shell scripts :

  • Create-MMS2013SessionFile.ps1 –> This file creates the sessions.txt file OR You can create sessions.txe and add all the Sessions codes for Ex:DC-B309.wmv and save the file.
  • MMS2013_Downloader.ps1 –> This file downloads the sessions which you have given in sessions.txt file.

Download the scripts from Sky drive,save it in one folder.I have listed out all SCCM Configmgr 2012 Sessions codes here,save it in same folder where you placed the scripts.

If you get any error like “script cannot be loaded”while running MMS2013_downloader.ps1 script to download the sessions,you may have to try setting execution policy to unrestricted.

image thumb Script to Download all MMS 2013 SCCM Configmgr 2012 Sessions Command line : Set-ExecutionPolicy Unrestricted

Try running the script now.During this process,it may prompt you security warning,Press Y.

image thumb1 Script to Download all MMS 2013 SCCM Configmgr 2012 Sessions

Next it ask for path to download the sessions with folder creation inside it called MMS2013Sessions.

Read Complete post Via http://blog.scomfaq.ch/2013/04/10/mms-2013-download-sessions-offline-viewing/

Enojy !

Tags: , , ,
Posted in CM2012, ConfigMgr (SCCM), Configmgr2012, MMS 2013, PowerShell, SCCM 2012, Scripting | 4 Comments »

SCCM VBScript to add shortcut files to users desktop profile OR favorites

Posted by Eswar Koneti on 1st April 2013

How to add link URL or shortcut file to users desktop profile ? Easiest way to accomplish this task is with GPO(Group policy Object).

If you want to accomplish this task using Configuration manager(SCCM),you can create simple VB script that does this job.

 

Option Explicit
dim path
path=CreateObject(“WScript.Shell”).ExpandEnvironmentStrings(“%UserProfile%\desktop“)
dim objFSO
set objFSO=CreateObject(“Scripting.FileSystemObject”)

If objFSO.FileExists(path & (“\eskonr.url“)) = False Then

objFSO.CopyFile “\\servername\folder name\eskonr.url“, path & “\”

end if

Full Details http://social.technet.microsoft.com/Forums/en-US/configmgrswdist/thread/ba1647a1-0385-48a9-9e83-1fc5daa00976/#e9d4f330-500e-45db-b3e1-5e3954f50ea4

Tags: , , , , , , , ,
Posted in ConfigMgr (SCCM), Configmgr2012, SCCM 2007, Scripting, VB Script | No Comments »

SCCM Configmgr 2007 Script move packages to Archive Folder

Posted by Eswar Koneti on 13th March 2013

This is Continuation to previous post package archival process.up on the query results,I would not delete the packages from console directly rather i delete them from its assigned Distribution points and move them to Archive folder and let be there for sometime until for sometime incase if it is required.

If you have large number of packages,you may find difficult in moving the packages by identifying where they reside (if you have subfolders).If you have less packages <10,you may use the report to know the root path of the package  and then right click on the package Move to archive folder by appending Retired to the existing package name to know package is retired.

If you have multiple packages,moving one by one is not easy thus you require something like script or tools.

Moving package using script may require to get the Source folder ContainerID number of  the packages(Folder of the package)  and Destination Folder ContainerID(Archival folder ID).

Here is the SQL query for the list of moving packages to know their Source Folder ContanerID.

 image thumb SCCM Configmgr 2007 Script move packages to Archive Folder

From the package clean up report,if you get multiple packages,just place them in IN condition separated by comma (,).

I have packageID cen00004 which i need to move to archive folder with containerID=4 from SQL query below

select  B.ContainerNodeID,B.NAME,A.InstanceKey from dbo.FolderMembers a,.dbo.Folders b where
a.ContainerNodeID=b.ContainerNodeID and b.Name like ‘%archive%’

Replace the folder name if you have other one.

Now we have list of packages with their source ContainerNodeID(which is nothing  but the package FolderID).

Create a VB script with below syntax with input of all package IDs separated by commas with their source folder and destination folder.

Note : Please replace quotes (‘”) as they are replaced by fancy.

Option Explicit
‘On error resume next

Dim strSMSServer, strSMSSiteCode, strPackageIDs
Dim intSourceFolder, intDestFolder, intObjectType
Dim loc, objSMS
Dim objFolder
Dim arrPackageIDs
Dim retval

strSMSServer   = "SCCM server Name"
strSMSSiteCode = "SiteCode"
strPackageIDs  = inputbox("Please input packageIDs separated by commas","List of packages to be moved")

intSourceFolder =inputbox("Please input Source folder ContainerID number", "Source ContainerID")  ‘This ID is what you see in above SQL query to move all packages from the same folder test =1.
intDestFolder   =4 ‘Destination Folder for Archived packages :In this case,My archive package folder is 4.

intObjectType   = 2  ’2=Package for type of object .This scripts works only for standard software distribution packages.

Set loc         = CreateObject("WbemScripting.SWbemLocator")
Set objSMS      = loc.ConnectServer(strSMSServer, "root\SMS\site_" & strSMSSiteCode)

Set objFolder = objSMS.Get("SMS_ObjectContainerItem")
arrPackageIDs = Split(strPackageIDs, ",")

retval = objFolder.MoveMembers(arrPackageIDs, intSourceFolder , intDestFolder , intObjectType)
If Err.Number <> 0 Then
    msgbox Err.Description
End If

MSGBOX "Script is completed"

You may get multiple packages with different source Folders.So you will have to run the script to move bulk packages from each source folder to Destination at one go.

It is better than moving one by one package each time.

Hope it helps!

Tags: , , , , , , ,
Posted in ConfigMgr (SCCM), SCCM, SCCM 2007, Scripting, Software Distribution, SQL Quiries | No Comments »

#SCCM / #Configmgr Script to delete packages from Assigned DPs

Posted by Eswar Koneti on 27th February 2013

Long ago ,written SCCM report to list packages not used for 6 months as part of Package Archival process http://eskonr.com/2012/11/sccm-configmgr-package-archival-process-cleanup-activity/ .This report tells you to take further action to clean or move to Archive folder to wait for some more months before it goes for Deletion.

What next ? Delete these packages from Assigned DPs to get some disk space ?

You may find several scripts to do this task on the internet but, i  find this is easy for me to get this activity done.

Identify list of package which you want to remove ,pipe them to notepad .You can do more customizations if needed.

Script to delete packages from its assigned Distribution Points.

strComputer =inputBox("Please Enter the SMS provider OR Site where the packages are created" , "SCCM Server name")
Set FSO = CreateObject("Scripting.FileSystemObject")
Set packages=fso.OpenTextFile("C:\PACKAGESTODELETE.txt",1,true)
Set objoutputfile=fso.OpenTextFile("C:\DP_results.txt",2,true)

Do While packages.AtEndOfLine <> True
    ‘read the next line
    package = packages.Readline

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\SMS\site_CEN")
if err.number<>0 then
    msgbox "server connection failed"
    wscript.quit
end if
Set colItems = objWMIService.ExecQuery("SELECT * FROM SMS_DistributionPoint where packageid=’" & Package & "’")
For Each objItem in colItems
        ‘Wscript.Echo "ServerNALPath: " & objItem.ServerNALPath
objoutputfile.WriteLine ( package & vbTab & " will be deleteting from" & VBTAB & objItem.ServerNALPath)

objitem.Delete_

If Err.number <> 0 Then

objoutputfile.WriteLine ( "Failed to delete" & vbTab & package & "from" &  vbTab & objItem.ServerNALPath)
      End If
    Next

loop

msgbox "Done"

Note: Please Replace the quotes.

Tags: , , , , ,
Posted in CM2012, ConfigMgr (SCCM), Configmgr2012, Distribution Point, SCCM 2007, SCCM 2012, SCCM Tools, Scripting, Software Distribution, System Center 2012 Configuration Manager, WMI | 1 Comment »

SCCM Configmgr 2012 Automation RC is available to Download

Posted by Eswar Koneti on 10th January 2013

Just saw an Email update from Myitforum list about the Release of Configuration Manager 2012 Automation RC is out now.

Few months back,he announced the release of Configmgr 2012 Automation Beta here.

To know more about what does the scripts do, http://wmug.co.uk/wmug/b/dotraphael/archive/2012/09/28/project-cm12-automation-beta-is-coming.aspx

To Download the scripts http://cm12automation.codeplex.com/releases/view/100135

Raphael is working on uploading the videos on YouTube on this also he will update his blog page once everything is there…

Hope you like it ! icon smile SCCM Configmgr 2012 Automation RC is available to Download

Tags: , , , , , , ,
Posted in Automation, CM2012, ConfigMgr (SCCM), Configmgr2012, Powershell, SCCM 2012, SCCM Tools, Scripting, Setup & Deployment, System Center 2012 Configuration Manager | No Comments »

SCCM Configmgr Clean Up Backlogs in Despooler.Box\Receive Folder

Posted by Eswar Koneti on 18th December 2012

SCCM Inbox Folders plays Vital Role in troubleshooting problems with different components. You should keep an Eye on the inbox folders for a backlog of files that wait to be processed.

There are various methods to monitor the inbox folders (tools/Scripts etc). This Post is going to be focus on Despooler.Box\Receive and clean up files residing older than 30 days.

Despooler.box\Receive stores the data that is received from a child site or a parent site and process it accordingly.Typically, files are processed and moved as soon as Configuration Manager 2007 receives the instruction file (.ins file).

In Short about what despooler does is  Despooler component receives the data and hands it off to Replication Manager component then Replication Manager hands the data to the appropriate component to process further.

But Due to some Reasons,Packages which are sending from hierarchy to child sites stuck and breaks the thread and it again starts sending from beginning.Because of this,files remains in Receive folder without being processed for longer time.

If you are in small environment (less than 10 sites or so) you can check it manually by looking at Despooler.Box\Receive what files are Old based on modified date and remove them.

Here is simple VB script that looks for the folder name and get file name,Size and modifieddate. If the Despooler is receiving any files from its parent, you get current date.

Set fso = CreateObject(“Scripting.FileSystemObject”)
Set objinputfile=fso.OpenTextFile(“C:\Scripts\Servers.txt”,1,True)
Set objoutputfile=fso.OpenTextFile(“C:\Scripts\Results.csv”,2,True)
Do While Not objinputfile.AtEndOfStream
strcomputer=objinputfile.ReadLine
Set recive = fso.GetFolder(“\\” & strComputer & “\Driveletter$\SCCM\inboxes\despoolr.box\receive“)
Set colFiles = recive.Files
For Each objFile in colFiles

objoutputfile.WriteLine strComputer & vbTab & objFile.Name & vbTab & objFile.size & vbTab & objFile.DateLastModified

Next
loop
msgbox(“done”)

Note : If you have sccm installed on different Drives with different folder names without unique ,this script may not be helpful to you.

Provide all the site names to servers.txt and results will be piped to results.csv file.

Once you get the results,you can sort it with File Size and Modifieddate to take further action.

I would prefer to delete the files from receive folder older than month.

Here you go with the script to delete files from despoolr.box\receive older than 30 days:

 

Set fso = CreateObject(“Scripting.FileSystemObject”)
Set objinputfile=fso.OpenTextFile(“C:\Scripts\desplooer-servers.txt”,1,True)
Set objoutputfile=fso.OpenTextFile(“C:\Scripts\despooler-results.csv”,2,True)
Do While Not objinputfile.AtEndOfStream
strcomputer=objinputfile.ReadLine

Set objWMIService = GetObject(“winmgmts:\\” & strComputer)
If Err.Number <> 0 Then
objoutputfile.WriteLine (strcomputer & ” is not Up or problem in connecting to WMI”)
Err.Clear
Else
strDays= 30
Set recive = fso.GetFolder(“\\” & strComputer & “\f$\SMS\inboxes\despoolr.box\receive”)
Set colFiles = recive.Files
For Each objFile in colFiles
If DateDiff(“d”, objFile.DateLastModified, Date) > strDays Then
fso.DeleteFile(objFile)
objoutputfile.WriteLine strComputer & vbTab & “Deleted”
end if

Next
end if
loop
msgbox(“done”)

Until then !

Tags: , , , , , , ,
Posted in CM2012, ConfigMgr (SCCM), Configmgr2012, Distribution Point, Replication, SCCM 2007, Scripting, Secondary Site, Setup & Deployment, System Center 2012 Configuration Manager, Trobleshooting Tips | No Comments »

How to get AD computer info into #SCCM / #Configmgr 2007/2012 Database ?

Posted by Eswar Koneti on 11th December 2012

Getting AD information into SCCM Database can be done using AD discovery Methods From SCCM Configmgr but there are cases where in some of the computers may not be discovered or Computers do not exist in AD but do available in SCCM Database.

I used MaikKoster Old blog post as reference and made some customizations/Updates in the query to retrieve information about only Active Computers (Exclude disabled Machines).

Comparing AD Computer information with SCCM Database sometimes interesting to know about client health and are there any missing out clients did not discover into SCCM Database.

This also helps you to focus more on clients inventory issues .There are cases where in User will be logged into domain(last logon timestamp) but client will not report to site .With this you can create hardware inventory report for computers not reported with in X number of Days with AD last logon Timestamp.(if your discovery is not customized and run frequently).

You can use this procedure in SMS 2003, SCCM 2007 and SCCM 2012 environments.

Updated : Please be clear what information do you want to retrieve from AD into SCCM Database in the initial phase else you may lead to an issue to update the existing table with custom values.

I tried adding more attributes from AD to the existing SQL Job what is already been created but i failed . I have to drop the table ,Change the query and run the job to make it Work.

This procedure requires you to download Log Parser (http://www.microsoft.com/en-us/download/details.aspx?id=24659) and install it on CM server.If your SQL hosting on different Box,Install it on SQL Box with default settings (next,next,next,close icon smile How to get AD computer info into #SCCM / #Configmgr 2007/2012 Database ? )

Start SQL server Management Studio

image thumb7 How to get AD computer info into #SCCM / #Configmgr 2007/2012 Database ?

Move onto SQL server Agent—>Jobs—>Create New Job

image3 thumb How to get AD computer info into #SCCM / #Configmgr 2007/2012 Database ?

On the General Tab,Enter the required Fields as per appropriate.

image67 thumb How to get AD computer info into #SCCM / #Configmgr 2007/2012 Database ?

Move to Next tab Steps .This is the step where you Create Job to execute and get AD computer Information into SCCM Database.

Click on New

image61 thumb How to get AD computer info into #SCCM / #Configmgr 2007/2012 Database ?

You are prompted to select Different fields like Step Name (AD info), Type(ActiveX Script) and Run as(SQL server Agent Service Account).

Next is to import the the script to execute. Download the Script from Maikkoster website here and Import it using Open.

image21 thumb How to get AD computer info into #SCCM / #Configmgr 2007/2012 Database ?

Once you are imported , you are required to supply values for the below Objects :

strLDAP = “LDAP://eskonr.com
strSQLServer = “sccmSQL
strDatabase = “SMS_CEN
strTable = “ADComputersInfo

Note: Strtable is Table not view

Replace the below customized query with existing One after ‘ Create query text

strQuery = “SELECT cn, objectpath, operatingSystem, operatingSystemServicePack”
strQuery = strQuery & “, CASE LastLogonTimestamp WHEN 0 THEN NULL ELSE ”
strQuery = strQuery & ” TO_TIMESTAMP(ADD(DIV(TO_REAL(LastLogon), 10000000.0), TO_REAL(TIMESTAMP(’1601′,’yyyy’)))) END AS [LastLogon]”
strQuery = strQuery & “, CASE pwdLastSet WHEN 0 THEN NULL ELSE ”
strQuery = strQuery & ” TO_TIMESTAMP(ADD(DIV(TO_REAL(pwdLastSet), 10000000.0), TO_REAL(TIMESTAMP(’1601′,’yyyy’)))) END AS [PwdLastSet]”
strQuery = strQuery & ” INTO ” & strTable & ” FROM”
strQuery = strQuery & “‘” & strLDAP & “‘” & ” where ”
StrQuery = strQuery & “userAccountControl” & “=” & “4096″

Note : You can do customizations to the above query depends on your requirement.

“Please replace the Quotes as the blog converts them to fancy ”

Click Ok.

Go to Schedule Tab,Click New

image53 thumb How to get AD computer info into #SCCM / #Configmgr 2007/2012 Database ?

Schedule it as per the requirement.

image27 thumb How to get AD computer info into #SCCM / #Configmgr 2007/2012 Database ?

Click on Ok, OK

Start the job which we created now.

image33 thumb How to get AD computer info into #SCCM / #Configmgr 2007/2012 Database ?

You see from below,Job is executed successfully.

image36 thumb How to get AD computer info into #SCCM / #Configmgr 2007/2012 Database ?

Now its time to create Various reports based on your needs.

Simple report to list Computers which are not available in SCCM but do Exist in AD as Active.

SELECT [cn] AS ‘Computer Name’
,[ObjectPath] AS ‘Path’
,[operatingSystem] AS ‘OS’
,[operatingSystemServicePack] AS ‘SP’
,[LastLogon]
,DATEDIFF(dd, [LastLogon], getdate()) AS ‘days LastLogon’
,[PwdLastSet]
,DATEDIFF(dd, [PwdLastSet], getdate()) AS ‘days PwdLastSet’
FROM [DatabaseName].[dbo].[tablename]
WHERE cn NOT IN (SELECT name0 FROM v_GS_Computer_System)
ORDER BY LastLogon

Replace the Database name and table what you given in VB Script earlier.
Until Next !

Tags: , , , , , , , , ,
Posted in CM2012, ConfigMgr (SCCM), Configmgr2012, SCCM 2007, SCCM 2012, Scripting, Setup & Deployment, System Center 2012 Configuration Manager | 7 Comments »

#SCCM / #configmgr 2012 Open Resource Explorer Without SCCM Console

Posted by Eswar Koneti on 1st December 2012

In My Previous post , we get to connect Resource Explorer of Computer without Using SCCM Console in SCCM 2007.http://eskonr.com/2012/12/sccm-configmgr-2007-open-resource-explorer-without-sccm-console/

You can use the same script for sccm 2012 but with littlie changes to the folder names and File names.

Here is the Batch script to connect to resource Explorer of Client Computer in SCCM 2012 without Launching SCCM 2012 Console.

Change the Values in Red Color.

:start
@echo off
CLS
Title Resource Explorer by ESKONR
> temp.vbs ECHO WScript.Echo InputBox( "To which Computer would you like to connect?", "Resource Explorer By ESKONR", "Enter Computer Name" )
FOR /F "tokens=*" %%A IN (‘CSCRIPT.EXE //NoLogo temp.vbs’) DO SET dator=%%A
DEL temp.vbs
F:
cd
\SMS\AdminConsole\bin
SET var=’%dator%’
start resourceexplorer.exe -s -sms:ResExplrQuery="SELECT ResourceID FROM SMS_R_SYSTEM WHERE NAME = %var%" -sms:connection=\\Server\root\sms\site_%Sitecode%
exit
:end

Until Next!

Tags: , , , , , , , , ,
Posted in SCCM 2012, SCCM Tools, Scripting, SQL Quiries, Trobleshooting Tips | No Comments »

#SCCM /#Configmgr 2007 Open Resource Explorer without SCCM console

Posted by Eswar Koneti on 1st December 2012

 image thumb #SCCM /#Configmgr 2007 Open Resource Explorer without SCCM console

Connecting to Resource Explorer of Computer is always not good(takes time) to Search for computer in SCCM collection

and move further.Some times you may not find the computer in the collection where you are looking at then you comeback

and look in All desktops and servers which may take time  to load all computers and then offers you to search for computer.

Come up with Simple Batch script that prompt you to enter Computer name and it takes you to Resource Explorer of Computer.

You may require to edit the fields in Red Color for SCCM Installation Folder,SCCM server name and sitecode

:start
@echo off
CLS
Title Resource Explorer By ESKONR
> temp.vbs ECHO WScript.Echo InputBox( "To which Computer would you like to connect?", "Resource Explorer by ESKONR", "Enter Computer Name" )
FOR /F "tokens=*" %%A IN (‘CSCRIPT.EXE //NoLogo temp.vbs’) DO SET dator=%%A
DEL temp.vbs
F:
cd \SCCM\AdminUI\bin
SET var=’%dator%’
start resourceexplorer.msc -s -sms:ResExplrQuery="SELECT ResourceID FROM SMS_R_SYSTEM WHERE NAME = %var%" -sms:connection=\\%SCCM SERVER%\root\sms\site_%SITECODE%
exit
:end

Thanks to my Old Friend Marcus!

Until Then!

Tags: , , , , , , ,
Posted in SCCM 2007, SCCM 2012, SCCM Tools, Scripting, Trobleshooting Tips | No Comments »

SCCM 2007 Robocopy syntax copying PCK files

Posted by Eswar Koneti on 2nd November 2012

If you have any issues with distribution of any packages to child sites or if you are in multi-tier hierarchy,You get face issues with packages not replicating to child sites due to several reasons and they will be retrying n (specific) number of times until they get right version of PCK file.

Preload is Our Friend to fix Package replication issues in better way. To know more about Preload Tool  and its usage http://blogs.technet.com/b/configurationmgr/archive/2009/05/07/configmgr-2007-the-preload-package-tool-preloadpkgonsite-exe-explained.aspx

How do you copy the PCK files ? Via Network Share ? sending them Via disk if you have large number of packages (this may happen when building new site) or different method ?

I use Robocopy oftenly if there are any Big Packages(more than 1GB or even less you can use) to copy even if there are any network breakage/Restart, it keeps retry.

Here is the syntax used to copy the PCK file.

robocopy sourcename Destination [Filename /Z

Ex: robocopy \\CM07\f$\smspkg  G:\smspkg\ Cen00C01.pck /z

/Z : copy files in restartable mode

To know more about Robocopy ,use Robocopy /?

Download Robocopy from here

Tags: , , , , , , , ,
Posted in Robocopy, SCCM, SCCM 2007, Scripting, Software Distribution, Trobleshooting Tips | No Comments »