BizTalk – Rename Output File Based on Some Attribute in Orchestration

  1. Create an Orchestration string variable (in this case testVAR)
  2. Add assignment shape with code below
  3. Change the send location output file name to %SourceFileName%

    [sourcecode language=”csharp”]
    outputMessage = outputMessage ;

    testVAR = xpath(outputMessage,"string(/*[local-name()=’SomeName1′ and namespace-uri()=’SomeSchema’]/*[local-name()=’SomeName2′ and namespace-uri()=”]/*[local-name()=’SomeName3′ and namespace-uri()=”]/text())");

    outputMessage(FILE.ReceivedFileName) = testVAR + ".TXT";
    [/sourcecode]

     

Remotely Rename A Computer

Remotely rename a computer and its Active Directory account using PSExec and batch file (vbs dropper)

Usage: PSExec.exe \\CURRENTCOMPUTERNAME -c -d -f RenameComputer.bat NEWCOMPUTERNAME
(Account needs Admin on target computer and modify rights on computer object in AD)

RenameComputer.bat
[sourcecode language=”plain”]
@ECHO OFF
ECHO Option Explicit > RenameComputer.vbs
ECHO. >> RenameComputer.vbs
ECHO On Error Resume Next >> RenameComputer.vbs
ECHO. >> RenameComputer.vbs
ECHO Dim objWMIService >> RenameComputer.vbs
ECHO Dim colComputers >> RenameComputer.vbs
ECHO Dim objComputer >> RenameComputer.vbs
ECHO Dim varError >> RenameComputer.vbs
ECHO. >> RenameComputer.vbs
ECHO Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") >> RenameComputer.vbs
ECHO. >> RenameComputer.vbs
ECHO Set colComputers = objWMIService.ExecQuery("Select * from Win32_ComputerSystem") >> RenameComputer.vbs
ECHO. >> RenameComputer.vbs
ECHO For Each objComputer in colComputers >> RenameComputer.vbs
ECHO varError = objComputer.Rename("%1") >> RenameComputer.vbs
ECHO Next >> RenameComputer.vbs
ECHO WScript.Echo varError >> RenameComputer.vbs

CScript //NOLOGO RenameComputer.vbs
DEL RenameComputer.vbs

Shutdown -r -f -t 60
[/sourcecode]