none
Trying to pass string OUPATH in my javscript file during OSD MDT deployment. How to do I do this correctly? RRS feed

  • General discussion

  • I have an hta and javascript file that requests different pieces of AD info and passes them along to our server during deployment. I have been trying to get the string OU path to pass but am not able to. Each time I get an error that tells me its not a valid function.

    The string is called OUPATH below, I call this webservice in my task sequence during deployment after applying networking settings and it should take the value from the users input during the drop down selection. 

    WebService=http://YourWebServer/YourWSFolder/AD.asmx/MoveComputerToOU 
    Parameters=OSDComputerName,MachineObjectOU 
    OSDComputerName=ComputerName 
    MachineObjectOU=OUPath

    How do I write my java code to pass this info once a user has selected the option from the drop down? I've been working on this all week and can't seem to figure this out.

     function OUPath() 
    {
    var myVal = document.getElementById("ADOU").value;
    var outPut = "";
    switch (myVal) {
    case "1":
    outPut = "OU=Administrative,OU=Workstations,DC=imo-online,DC=com";
    break;
    case "2":
    outPut = "OU=Development,OU=Workstations,DC=imo-online,DC=com";
    break;
    case "3":
    outPut = "OU=External,OU=Workstations,DC=imo-online,DC=com";
    break;
    case "4":
    outPut = "OU=IT,OU=Workstations,DC=imo-online,DC=com";
    break;
    case "5":
    outPut = "OU=Restricted,OU=Workstations,DC=imo-online,DC=com";
    break;
    case "6":
    outPut = "OU=Sales,OU=Workstations,DC=imo-online,DC=com";
    break;
    case "7":
    outPut = "OU=Service Computers,OU=Workstations,DC=imo-online,DC=com";
    break;
    }
    alert(outPut);
    }

    The whole code is here

    var oTimer;
    
    // This is the javascript backend for the The BitLocker FrontEnd HTA - CM12 ver 3.0, Jan, 2013.
    // report bugs, suggestions, corrections, fixes etc to niall@windows-noob.com or visit windows-noob.com
    // 
    // Below are the functions used in the HTA
    
    function searchcomputer(searchstring ) {
    	var WShell = new ActiveXObject("WScript.Shell");
    	var oEnvironment = new ActiveXObject("Microsoft.SMS.TSEnvironment");
    	oEnvironment("SearchString")=searchstring;
    	var oExec = WShell.Run ("cscript //NoLogo " + GetScriptRoot() + "\\wnb\\searchcomputerbyname.wsf", 0, true);
    	return oEnvironment("search_Computer");
    	}
    	
    function performeComputerSearch() {
            var searchString = '';
            var searchTextBox = document.getElementById('searchstring_association');
            var searchReturnedResult = false;
    
            /* 
            Clear the drop down from previous searches and add the first default element to the drop down. 
            ----------------------------------------------------------------------------------------------- 
            */
    
            var el = document.getElementById("destinationComputerList");
    
            /* Clear drop down list. */
            while(el.options.length > 0)
                el.options.remove(0);
    
    
            /* Create first element, showing that the user has to select an element from the drop down list. */
            var opt1 = document.createElement("option");
            el.options.add(opt1);
            opt1.text = 'Select destination';
            opt1.value = '';
    
     
            /* 
            --------------------------------------------------------------------------------------------------
            Drop down blanked and first default value is added. 
            */
    
            if( searchTextBox != null ) {
                searchString = searchTextBox.value;
                if( searchString != '' ) {
                    
    
    				searchcomputer(searchString );
    		var oEnvironment = new ActiveXObject("Microsoft.SMS.TSEnvironment");
    		var currentComputerResourceId = oEnvironment("GetResourceId");
            /* When web service returns process the result. */
            var html = new ActiveXObject("Microsoft.XMLDOM");
    
    		/* Here extract the result from the oEnviroment , remeber to create the oEnviorment object if it's not created before. */
    		var result = oEnvironment("search_Computer");
    		// alert(result);
            	
        
            html.loadXML(result);
    
    
                   /* Retrive all the computers in the search result. */
            var anodes = html.selectNodes("//Resource");
             
    
                    /* Create drop down elements base on the */
                    
            for (var i=0; i < anodes.length; i++){
            var obsolete = anodes(i).selectSingleNode("Obsolete").text;
    		var resourceid = anodes(i).selectSingleNode("ResourceID").text;
                        if( obsolete == 'false' && currentComputerResourceId != resourceid ) {
                            /* Computer is not Obsolete, added it to the drop down. */
                            var name = anodes(i).selectSingleNode("Name").text;
                            // alert (name);
                            var SMSUniqueIdentifier= anodes(i).selectSingleNode("ResourceID").text;
    
                            var opt = document.createElement("option");
    
                            // Add an Option object to Drop Down/List Box
                            el.options.add(opt);
                            // Assign text and value to Option object
                            opt.text =  'ResourceID: ' + SMSUniqueIdentifier + ',   Name: ' + name;
                            opt.value = resourceid;
    
                            searchReturnedResult = true;
                        }
                    }            
    
                }
                if( searchReturnedResult == false ) {
                    alert( "Query for '" + searchString + "' didn't return any computer to make association with, please redefine your search string." );
                }
    
            }
        }
    
       function makeAssociation () {
            /* Make sure that the user has selected a destination computer. */
    
            var el = document.getElementById("destinationComputerList");
            var selectedresourceId = el.value;
    
            if( selectedresourceId == '' ) {
                /* User havn't selected a computer to make association with. */
                alert('No destination computer selected' );
    
            } else {
    
                /* Call the other web service to make the association.  */
                alert( 'The selected ResourceId  is: ' + selectedresourceId);
    			var answer = makeAssosiationWebServiceCall(selectedresourceId);
    if(answer == "True" ){
    alert("Successfully Associated Computers");
    
    } else {
    alert(answer + 'UnSuccessfully Associated Computers');
    }
    
            } 
            
        }
    	
    	
    function IdentifySCCMDrive()
    {
    	var fso = new ActiveXObject("Scripting.FileSystemObject");
    	var oEnvironment = new ActiveXObject("Microsoft.SMS.TSEnvironment");
    	var drives = new Enumerator(fso.Drives);
    
    	for(drives.moveFirst();!drives.atEnd();drives.moveNext())
    	{ 
    		var drive = drives.item();
    		if(drive.IsReady && fso.fileexists(drive.path + "\\SMS\\data\\TsmBootstrap.ini"))
    		{
    			var fileContents = fso.OpenTextFile(drive.Path + "\\SMS\\data\\TsmBootstrap.ini").ReadAll();
    			if(fileContents.search("MediaType=FullMedia") > -1)
    			{
    				oEnvironment("SCCMDRIVE") = drive.Path;
    				return drive.Path;
    			}
    		}
    	}		
    }
    	
    function makeAssosiationWebServiceCall(dest){
    var WShell = new ActiveXObject("WScript.Shell");
    
    	var oEnvironment = new ActiveXObject("Microsoft.SMS.TSEnvironment");
        oEnvironment("ReferenceComputerResourceId") = oEnvironment("GetResourceId");
        oEnvironment("DestinationComputerResourceId") = dest;
    	var oExec = WShell.Run ("cscript //NoLogo " + GetScriptRoot() + "\\wnb\\AddComputerAssociationbyID.wsf", 0, true);
    	return oEnvironment("AddComputerAssociationByIDResult");
    	
       }
    
    function OnLoad()
    {
    	var WShell = new ActiveXObject("WScript.Shell");
    	var oEnvironment = new ActiveXObject("Microsoft.SMS.TSEnvironment");
    	document.getElementById('txtComputerNew').value = oEnvironment("OSDCOMPUTERNAME");
    
    	var oTSProgressUI = new ActiveXObject("Microsoft.SMS.TSProgressUI");
    	oTSProgressUI.CloseProgressDialog();
    	GetTSVersion();
    	GetUSMTVersion()
    	IdentifySCCMDrive();
    	populateUSMTDropList();
    
    	
    	
    	if(oEnvironment("TPM_Available") == "True")
    	{
    	document.getElementsByName("RefreshckBoxEnableBitLocker").item(0).disabled = false;
    	document.getElementsByName("NewComputerckBoxEnableBitLocker").item(0).disabled = false;
    	}
    	document.title = "The CM12 BitLocker FrontEnd HTA";
    }
    
    
    function inpBoxUser_OnKeyUp(strCaller)
    {
    	if(oTimer != undefined)
    		window.clearTimeout(oTimer);
    		
    	document.getElementById('txtUserRefresh').value = document.getElementById(strCaller).value;
    	document.getElementById('txtUserNew').value = document.getElementById(strCaller).value;
    
    	oTimer = window.setTimeout("doADCheck('" + strCaller + "')", 2000);
    	
    }
    
    function inpBoxComputer_OnKeyUp(strCaller)
    {
    	if(oTimer != undefined)
    		window.clearTimeout(oTimer);
    		
    //	document.getElementById('txtComputerRefresh').value = document.getElementById(strCaller).value;
    	document.getElementById('txtComputerNew').value = document.getElementById(strCaller).value;
    
    	oTimer = window.setTimeout("doADCheck('" + strCaller + "')", 2000);
    	
    }
    
    
    function doADCheck(strCaller)
    {
    	strFullName = GetRealName(document.getElementById(strCaller).value);
    	
    	if (strFullName == "NOACCOUNT") {
    		document.getElementById('txtUserNew').style.background = "#EC736A";
    		document.getElementById('txtUserRefresh').style.background = "#EC736A";
    		document.getElementById('txtUserInfoNew').innerHTML = "";
    		document.getElementById('txtUserInfoRefresh').innerHTML = "";
    	}
    	else if(strFullName == "SERVFAIL") {
    		document.getElementById('txtUserNew').style.background = "#FFA61C";
    		document.getElementById('txtUserRefresh').style.background = "#FFA61C";
    		document.getElementById('txtUserInfoNew').innerHTML = "SERVER FAILURE";
    		document.getElementById('txtUserInfoRefresh').innerHTML = "SERVER FAILURE";
    	}
    	else 
    	{
    		document.getElementById('txtUserNew').style.background = "#6EC6F0";
    		document.getElementById('txtUserRefresh').style.background = "#6EC6F0";
    		document.getElementById('txtUserInfoNew').innerHTML = strFullName;
    		document.getElementById('txtUserInfoRefresh').innerHTML = strFullName;
    	}
    
    	if (document.getElementById(strCaller).value.length == 0) {
    		document.getElementById('txtUserNew').style.background = "#FFFFFF";
    		document.getElementById('txtUserRefresh').style.background = "#FFFFFF";
    		document.getElementById('txtUserInfoNew').innerHTML = "";
    		document.getElementById('txtUserInfoRefresh').innerHTML = "";
    	}
    }
    
    function GetRealName (strUserName)
    {
    	var WShell = new ActiveXObject("WScript.Shell");
    	var oEnvironment = new ActiveXObject("Microsoft.SMS.TSEnvironment");
    	var oExec = WShell.Run ("cscript //NoLogo " + GetScriptRoot() + "\\wnb\\UserNameHelper.wsf /USERNAME:" + strUserName, 0, true);
    	return oEnvironment("UserFullName");
    }
    
    function GetScriptRoot ()
    {
    	var oEnvironment = new ActiveXObject("Microsoft.SMS.TSEnvironment");
    	return oEnvironment("SCRIPTROOT");
    }
    
    function Shutdown()
    {
    	var WShell = new ActiveXObject("WScript.Shell");
    	if(window.confirm("Ok to shutdown?"))
    		WShell.Run ("wpeutil shutdown",0, true);	
    }
    
    function Reboot()
    {
    	var WShell = new ActiveXObject("WScript.Shell");
    	if(window.confirm("Ok to reboot?"))
    		WShell.Run ("wpeutil reboot",0, true);	
    }
    
    function closeHTA()
    {
    	var WShell = new ActiveXObject("WScript.Shell");
    	if(window.confirm("Ok to Exit?"))
    		WShell.Run ("wpeutil shutdown",0, true);		
    }
    
    function commandPrompt()
    {
    var WShell = new ActiveXObject("WScript.Shell");
    //	if(window.confirm("Open Command Prompt?"))
    		WShell.Run ("cmd.exe /k",1, true);
    }
    
    function cmtrace()
    {
    var WShell = new ActiveXObject("WScript.Shell");
    //	if(window.confirm("Open Command Prompt?"))
    		WShell.Run ("cmd.exe /k viewlog.cmd",1, true);
    }
    
    function showreport()
    {
    	var oEnvironment = new ActiveXObject("Microsoft.SMS.TSEnvironment");
    		alert(oEnvironment("UUID"));	
    }
    
    function GetSCCMAssignedSite()
    {
    	var WShell = new ActiveXObject("WScript.Shell");
    	var oEnvironment = new ActiveXObject("Microsoft.SMS.TSEnvironment");
    	var oExec = WShell.Run ("cscript //NoLogo " + GetScriptRoot() + "\\wnb\\sitecode.wsf", 0, true);
    	return oEnvironment("SiteCode");
    } 
    
    function IsComputerKnown()
    {
    	var WShell = new ActiveXObject("WScript.Shell");
    	var oEnvironment = new ActiveXObject("Microsoft.SMS.TSEnvironment");
    	var oExec = WShell.Run ("cscript //NoLogo " + GetScriptRoot() + "\\wnb\\IsComputerKnown.wsf", 0, true);
    	return oEnvironment("IsComputerKnown");
    } 
    
    function OUPath() 
    {
    var myVal = document.getElementById("ADOU").value;
    var outPut = "";
    switch (myVal) {
    case "1":
    outPut = "OU=Administrative,OU=Workstations,DC=imo-online,DC=com";
    break;
    case "2":
    outPut = "OU=Development,OU=Workstations,DC=imo-online,DC=com";
    break;
    case "3":
    outPut = "OU=External,OU=Workstations,DC=imo-online,DC=com";
    break;
    case "4":
    outPut = "OU=IT,OU=Workstations,DC=imo-online,DC=com";
    break;
    case "5":
    outPut = "OU=Restricted,OU=Workstations,DC=imo-online,DC=com";
    break;
    case "6":
    outPut = "OU=Sales,OU=Workstations,DC=imo-online,DC=com";
    break;
    case "7":
    outPut = "OU=Service Computers,OU=Workstations,DC=imo-online,DC=com";
    break;
    }
    alert(outPut);
    }
    
    function GetComputerName()
    {
    	var WShell = new ActiveXObject("WScript.Shell");
    	var oEnvironment = new ActiveXObject("Microsoft.SMS.TSEnvironment");
    	var oExec = WShell.Run ("cscript //NoLogo " + GetScriptRoot() + "\\wnb\\GetComputerName.wsf", 0, true);
    	return oEnvironment("GetComputerName");
    } 
    
    function GetResourceID()
    {
    	var WShell = new ActiveXObject("WScript.Shell");
    	var oEnvironment = new ActiveXObject("Microsoft.SMS.TSEnvironment");
    	var oExec = WShell.Run ("cscript //NoLogo " + GetScriptRoot() + "\\wnb\\GetResourceID.wsf", 0, true);
    	return oEnvironment("GetResourceID");
    } 
    
    function getUserFriendlyBoolValue( value ) {
    	if ( value )
    		return "Yes";
    	else
    	 return "No";
    }
    
    function GetTSVersion()
    {
    	var oEnvironment = new ActiveXObject("Microsoft.SMS.TSEnvironment");
    	sversioninfo = oEnvironment("_SMSTSPackageName");
    	sHTML = "Task&nbsp;Sequence&nbsp;&nbsp;=&nbsp;&nbsp;" + sversioninfo ;
    	document.getElementsByName('DivTSVersion').item(0).innerHTML = sHTML;	
    }
    
    function GetUSMTVersion()
    {
    	var fso = new ActiveXObject("Scripting.FileSystemObject");
    	var oEnvironment = new ActiveXObject("Microsoft.SMS.TSEnvironment");
    	var drives = new Enumerator(fso.Drives);
    	var fileContents = "Unidentified Version"
    	
    	for(drives.moveFirst();!drives.atEnd();drives.moveNext())
    	{ 
    		var drive = drives.item();
    		if(drive.IsReady && fso.fileexists(drive.path + "\\_smstasksequence\\wdpackage\\usmt\\usmt_rulesets_version.txt"))
    		{
    			fileContents = fso.OpenTextFile(drive.Path + "\\_smstasksequence\\wdpackage\\usmt\\usmt_rulesets_version.txt").Read(25);
    			//alert(fileContents);
    		}
    	}
    	sHTML = "USMT&nbsp;RuleSet&nbsp;&nbsp;&nbsp;=&nbsp;&nbsp;" + fileContents ;
    	document.getElementsByName('DivUSMTVersion').item(0).innerHTML = sHTML;			
    }
    
    function ShowUSMTVersion()
    {
    	var fso = new ActiveXObject("Scripting.FileSystemObject");
    	var oEnvironment = new ActiveXObject("Microsoft.SMS.TSEnvironment");
    	var drives = new Enumerator(fso.Drives);
    	var fileContents = ""
    	
    	for(drives.moveFirst();!drives.atEnd();drives.moveNext())
    	{ 
    		var drive = drives.item();
    		if(drive.IsReady && fso.fileexists(drive.path + "\\_smstasksequence\\wdpackage\\usmt\\usmt_rulesets_version.txt"))
    		{
    			fileContents = fso.OpenTextFile(drive.Path + "\\_smstasksequence\\wdpackage\\usmt\\usmt_rulesets_version.txt").Read(25);
    			alert(fileContents);
    		}
    	}
    	sHTML = "USMT RuleSet&nbsp;&nbsp;=&nbsp;&nbsp;" + fileContents ;
    	document.getElementsByName('DivUSMTVersion').item(0).innerHTML = sHTML;			
    }
    
    function ShowVersion()
    {
    	var oEnvironment = new ActiveXObject("Microsoft.SMS.TSEnvironment");
    	alert('Task Sequence version=' +oEnvironment("_SMSTSPackageName"));
    }
    
    function populateUSMTDropList()
    {
    	var WShell = new ActiveXObject("WScript.Shell");
    	var fso = new ActiveXObject("Scripting.FileSystemObject");
    	var oEnvironment = new ActiveXObject("Microsoft.SMS.TSEnvironment");
    	 
    	sHTML = "<option value='NULL'>No Restore</option>\n";
    	sHTML = sHTML + "<option value='SMP'>SMP (Requires Computer Association)</option>\n";
    //	sUsmtStorePath = "c:\\USMTStores";
    	sUsmtStorePath = "\\\\sccm\\USMTStores";
    
    	if(fso.FolderExists(sUsmtStorePath))
    	{
    		var SubFolders = new Enumerator(fso.GetFolder(sUsmtStorePath).SubFolders);
    
    		for(SubFolders.moveFirst();!SubFolders.atEnd();SubFolders.moveNext())
    		{
    			var folder = SubFolders.item();
    			sLabel = folder.name ;
    			sValue = folder.name;
    			if (folder.name.toUpperCase() != "X86" && folder.name.toUpperCase() != "X64") 
    				sHTML = sHTML + "<option value='" + sValue + "'>" + sLabel + "</option>\n" ;
    		}		
    	}	
    	sHTML = "<select id='shareDropDown' name='shareDropDown'>\n" + sHTML + "</select>";
    	// You need to have a <div> in your HTML with the ID and NAME of divCboList
    
    	document.getElementsByName('divUSMTDropDown').item(0).innerHTML = sHTML;
    	
    }
    
    function buildConfirmationMessage( deploymentType, targetUser, targetComputer, dochkdsk, doBackup, doBackupNetwork, doOffline, regionValue, languageValue, BitLockervalue, ADOU, PreProvBitLockervalue, usmtvalue, AUTOComputerName, SCEPvalueRefresh, SCEPvalueNew, EnableBitLockerRefresh, ADOU, EnableBitLockerNew) {
        var arr = new Array();
        arr[arr.length] = "\r\n";
        arr[arr.length] = "Deployment type variable: ";
        switch(deploymentType) {
            case 0:
                 	arr[arr.length] = "BACKUPOLD";
    		arr[arr.length] = "\r\n";
    		arr[arr.length] = "Do CHKDSK: " + getUserFriendlyBoolValue( dochkdsk);
                	arr[arr.length] = "\r\n";
    		arr[arr.length] = "Do backup: " + getUserFriendlyBoolValue( doBackup);
                	arr[arr.length] = "\r\n";
    		arr[arr.length] = "Do backupNetwork: " + getUserFriendlyBoolValue( doBackupNetwork);
                	arr[arr.length] = "\r\n";
    		arr[arr.length] = "Do Offline: " + getUserFriendlyBoolValue( doOffline);
                	arr[arr.length] = "\r\n";
    
                break;
    	case 1:
                	arr[arr.length] = "REFRESH";
                	arr[arr.length] = "\r\n";
                	arr[arr.length] = "Do CHKDSK: " + getUserFriendlyBoolValue( dochkdsk);
                	arr[arr.length] = "\r\n";
    		arr[arr.length] = "Do backup: " + getUserFriendlyBoolValue( doBackup);
                	arr[arr.length] = "\r\n";
    		arr[arr.length] = "Do backupNetwork: " + getUserFriendlyBoolValue( doBackupNetwork);
                	arr[arr.length] = "\r\n";
    		arr[arr.length] = "Target user: " + targetUser;
    		arr[arr.length] = "\r\n";
    		arr[arr.length] = "AUTO-ComputerName: " + getUserFriendlyBoolValue( AUTOComputerName);
    		arr[arr.length] = "\r\n";
    		arr[arr.length] = "Enable SCEP: " + getUserFriendlyBoolValue( SCEPvalueRefresh);
    		arr[arr.length] = "\r\n";
    		arr[arr.length] = "EnableBitLockerRefresh: " + getUserFriendlyBoolValue( EnableBitLockerRefresh);
    		arr[arr.length] = "\r\n";
    		arr[arr.length] = "ADOU: " + getUserFriendlyBoolValue( ADOU);
    		arr[arr.length] = "\r\n";
    
                break;
    	case 2:
                	arr[arr.length] = "NEWCOMPUTER";
                	arr[arr.length] = "\r\n";
    		arr[arr.length] = "RegionValue: " + regionValue;
                	arr[arr.length] = "\r\n";
    		arr[arr.length] = "LanguageValue: " + languageValue;
                	arr[arr.length] = "\r\n";
                	arr[arr.length] = "Target user: " + targetUser;
                	arr[arr.length] = "\r\n";
    		arr[arr.length] = "Target computer: " + targetComputer;
                	arr[arr.length] = "\r\n";
    		arr[arr.length] = "AUTO-ComputerName: " + getUserFriendlyBoolValue( AUTOComputerName);
    		arr[arr.length] = "\r\n";
    		arr[arr.length] = "Enable SCEP: " + getUserFriendlyBoolValue( SCEPvalueNew);
    		arr[arr.length] = "\r\n";
    		arr[arr.length] = "EnableBitLockerNew: " + getUserFriendlyBoolValue( EnableBitLockerNew);
    		arr[arr.length] = "\r\n"; 
    		arr[arr.length] = "BitLockerdropdown: " + BitLockervalue;
    		arr[arr.length] = "\r\n"; 
    		arr[arr.length] = "\r\n";
    		arr[arr.length] = "Pre-Provision BitLocker: " + PreProvBitLockervalue;
    		arr[arr.length] = "\r\n"; 
    		arr[arr.length] = "USMTdropdown: " + usmtvalue;
                	arr[arr.length] = "\r\n";           	
    				
                break;
        }
    
        return "Please make sure your selections are ok before proceeding.\nYour Choices:-\n" + arr.join('');
    }
    
    function Proceed(actionToPerform) {
    	var deploymentType = '';
    	var targetUser = '';
    	var targetComputer = '';
        	var dochkdsk = '';
    	var doBackup = '';
    	var doBackupNetwork = '';
    	var AUTOComputerName  = '';
    	var EnableBitLockerRefresh = '';
    	var ADOU1 = '';
    	var EnableBitLockerNew = '';
    	var doOffline = '';
        	var regionValue = '';
    	var languageValue = '';
    	var BitLockerValue = '';
    	var PreProvBitLockerValue = '';
    	var SCEPvalueRefresh = '';
    	var SCEPvalueNew = '';
    var SCEPvalue = '';
    	var usmtvalue = '';
    	var oEnvironment = new ActiveXObject("Microsoft.SMS.TSEnvironment");
    
    
        // Extract the values.
      
    	switch (actionToPerform) {
    			
    		case 'Backup':
    		//	alert( 'You have chosen Backup.');
    			deploymentType = 0;
    			dochkdsk= document.getElementById('ckchkdsk').checked;
    			doBackup= document.getElementById('ckBoxFullBackup').checked;
    			doBackupNetwork= document.getElementById('ckBoxFullBackupNetwork').checked; 
    			doOffline= document.getElementById('ckBoxDoOffline').checked; 
    		break;
    					
    		case 'Reinstall':
    		//	alert( 'You have chosen Reinstall.');
    			deploymentType = 1;
    			dochkdsk= document.getElementById('Refreshckchkdsk').checked;
    			doBackup= document.getElementById('RefreshckBoxFullBackup').checked;
    			doBackupNetwork= document.getElementById('RefreshckBoxFullBackupNetwork').checked; 
    			doOffline= true; 	
    				if(document.getElementById('txtUserRefresh').value)
    				targetUser = document.getElementById('txtUserRefresh').value;
    				else
    				targetUser = "EMPTY";		
    			// targetUser = document.getElementById('txtUserRefresh').value;					
    			AUTOComputerName= document.getElementById('RefreshckBoxAUTO-ComputerName').checked;
    			SCEPvalue= document.getElementById('SCEPckBoxRefresh').checked;
    			EnableBitLockerRefresh= document.getElementById('RefreshckBoxEnableBitLocker').checked;
    			ADOU= document.getElementById('ADOU').checked;
    		
    		break;
    						
    		case 'Newcomputer':
    		//	alert( 'You have chosen New computer.');
    			deploymentType = 2;
    			var regionDrop = document.getElementById('regionDropDown');
    			var languageDrop = document.getElementById('languageDropDown');
    			var BitLockerDrop = document.getElementById('BitLockerDropDown');
    			var usmtdrop = document.getElementById('shareDropDown');
    			
    			
    			// added code to give targetUser a value if none entered
    			//
    				if(document.getElementById('txtUserNew').value)
    				targetUser = document.getElementById('txtUserNew').value;
    				else
    				targetUser = " ";
    			
    			// added code to give targetComputer a value if none entered
    			//
    				if(document.getElementById('txtComputerNew').value)
    				targetComputer = document.getElementById('txtComputerNew').value;
    				else
    				targetComputer = oEnvironment("OSDCOMPUTERNAME");
    			//AUTOComputerName = document.getElementById('ComputerNewckBoxAUTO-ComputerName').checked;
    			SCEPvalue= document.getElementById('SCEPckBoxNew').checked;		
    			EnableBitLockerNew = document.getElementById('NewComputerckBoxEnableBitlocker').checked;
    			BitLockerValue = BitLockerDrop.options[BitLockerDrop.selectedIndex].value;
    			ADOU1 = ADOU.options[ADOU.selectedIndex].value;
    			PreProvBitLockerValue = document.getElementById('ckBoxPreProvBitLocker').checked;
    			usmtvalue = usmtdrop.options[usmtdrop.selectedIndex].value;
    			
    		break;
    	
    		default:
    			// keep the values case sensitive !! If no type, Backup, Reinstall or New computer image is selected, the click on the Proceed 
    			// image will excute this section (between default: and break;. Keep it clear but DON'T remove the break.
    			// alert("'" + actionToPerform + "' isn't a valid selection.");
    			return;
    			break;
    			
    		}
    
         
            // Ask user if the values are ok to proceed with.
    
    		
            if(window.confirm( buildConfirmationMessage(deploymentType, targetUser, targetComputer, dochkdsk, doBackup, doBackupNetwork, doOffline, regionValue, languageValue, BitLockerValue,PreProvBitLockerValue, usmtvalue, AUTOComputerName, SCEPvalue, SCEPvalue, ADOU, EnableBitLockerRefresh, EnableBitLockerNew) ) ) {
    
    			//*
                var oEnvironment = new ActiveXObject("Microsoft.SMS.TSEnvironment");
                                                              
                window.moveTo(2000,2000);
                                                              
                                                              
                var WShell = new ActiveXObject("WScript.Shell");
    			
    			
                switch(deploymentType) {
                    case 0 :
                        	oEnvironment("DEPLOYMENTTYPE") = "BACKUPOLD";
    			oEnvironment("DOCHKDSK") = dochkdsk;
                        	oEnvironment("DOBACKUP") = doBackup;
    			oEnvironment("DOBACKUPNETWORK") = doBackupNetwork;
    			oEnvironment("DOOFFLINE") = doOffline;
                        break;
                    case 1:
                        	oEnvironment("DEPLOYMENTTYPE") = "REFRESH";
                        	oEnvironment("DOCHKDSK") = dochkdsk;
                        	oEnvironment("DOBACKUP") = doBackup;
    			oEnvironment("DOBACKUPNETWORK") = doBackupNetwork;
    			oEnvironment("TARGETUSER") = targetUser;
    			oEnvironment("DOOFFLINE") = doOffline;
    			oEnvironment("AUTOComputerName") = AUTOComputerName;
    			oEnvironment("SCEPvalue") = SCEPvalue;
    			oEnvironment("EnableBitLockerRefresh") = EnableBitLockerRefresh;
    			oEnvironment("ADOU1") = ADOU;
                        break;
                    case 2 :
                        	oEnvironment("DEPLOYMENTTYPE") = "NEWCOMPUTER";
                        	oEnvironment("RegionValue") = regionValue;
    			oEnvironment("LanguageValue") = languageValue;
    			oEnvironment("TARGETUSER") = targetUser;
                        	oEnvironment("OSDCOMPUTERNAME") = targetComputer;
    			oEnvironment("AUTOComputerName") = AUTOComputerName;
    			oEnvironment("SCEPvalue") = SCEPvalue;
    			oEnvironment("EnableBitLockerNew") = EnableBitLockerNew;
    	          	oEnvironment("BitLockerValue") = BitLockerValue;
    			oEnvironment("PreProvBitLockerValue") = PreProvBitLockerValue;
    			oEnvironment("uddir") = usmtvalue;
    	             break;
                }
    
                if(oEnvironment("_SMSTSMEDIATYPE") && oEnvironment("_SMSTSMEDIATYPE") == "FullMedia") {                                                                                     
                    oEnvironment("OSDStateStorePath") = oEnvironment("SCCMDRIVE") + "\\DiskBackups";
                }
    
                window.setTimeout('window.close()', 2000);
                 //*/                                           
            }
    		
    		
    }


    • Edited by kkonovalov Friday, December 19, 2014 3:44 PM
    Friday, December 19, 2014 3:43 PM

All replies

  • FYI,  here is my INI that I'm referencing via a Gather step.

    [MoveComputerToOU]
    ;OUPath must be specified prior to calling webservice.
    WebService=http://cm01.corp.viamonstra.com/WebService/ad.asmx/MoveComputerToOU
    Parameters=ComputerName,OUPath
    OSDComputerName=ComputerName

    I think including all of your code is throwing people off.  If you verified that your HTA is populating the desired variable like it should, then the above code is irrelevant.  Its probably something your doing in that INI.  I'd suggest adding a pause and just trial and erroring changes to the INI til you get the desired results.  Thats what I did.


    -BrianG (http://supportishere.com)

    Friday, December 19, 2014 9:16 PM
  • This is my INI i'm using

    [MoveComputerToOU]
    WebService=http://server/Deployment/ad.asmx/MoveComputerToOU
    Parameters=OSDComputerName,MachineObjectOU
    OSDComputerName=ComputerName
    MachineObjectOU=OUPath

    Should the parameters be OUPATH instead of MachineObjectOU?

    I will try the pause and trial next, it will save me a lot of time.

    Friday, December 19, 2014 10:19 PM
  • Also what is the best way to determine that my HTA is setting the variable properly. I am really new at this and could use all the suggestions I can get.
    Monday, December 22, 2014 6:41 PM