Im trying to execute a powershell script from a Scriptable task and passing input parameters as variable into my script for execution. I have posted the information below, I have no clue on this one. Any help would be appreciated.
My script is like this:
var session = PSHost.openSession()
// ------------------------
session.addCommandFromString("c:\\PowerShell\\ServerConfig.ps1 -IP ivo")
session.addCommandFromString("c:\\PowerShell\\ServerConfig.ps1 -Mask ivo")
session.addCommandFromString("c:\\PowerShell\\ServerConfig.ps1 -Gateway ivo")
session.addCommandFromString("c:\\PowerShell\\ServerConfig.ps1 -name ivo")
session.addCommandFromString("c:\\PowerShell\\ServerConfig.ps1 -username ivo")
//----------------------------
var cmd = session.addCommandFromString("c:\\PowerShell\\ServerConfig.ps1")
cmd.addParameter('IP');
cmd.addParameter('Mask');
cmd.addParameter('Gateway');
cmd.addParameter('name');
cmd.addParameter('username');
//----------------------------
res = session.invokePipeline();
System.error(res.getErrors());
System.log(res.getHostOutput());
PSHost.closeSession(session);
Here is my visual binding
Here is the error im getting when I get to this step:
[2017-10-03 12:25:19.569] [E] Error in (Workflow:Server Build Test / Scriptable task (item3)#9) java.lang.NullPointerException
[2017-10-03 12:25:19.579] [E] Workflow execution stack:
***
item: 'Server Build Test/item3', state: 'failed', business state: 'null', exception: 'java.lang.NullPointerException (Workflow:Server Build Test / Scriptable task (item3)#9)'
workflow: 'Server Build Test' (72804cdd-160b-4044-a23f-9934d1be193f)
| 'attribute': name=vmFolder type=VC:VmFolder value=dunes://service.dunes.ch/CustomSDKObject?id='tr01vpsvcntr002%2Cid:group-v517104'&dunesName='VC:VmFolder'
| 'attribute': name=powerOn type=boolean value=true
| 'attribute': name=template type=boolean value=false
| 'attribute': name=datastore type=VC:Datastore value=dunes://service.dunes.ch/CustomSDKObject?id='tr01vpsvcntr002%2Cid:datastore-467241'&dunesName='VC:Datastore'
| 'attribute': name=host type=VC:HostSystem value=dunes://service.dunes.ch/CustomSDKObject?id='tr01vpsvcntr002%2Cid:host-322517'&dunesName='VC:HostSystem'
| 'attribute': name=pool type=VC:ResourcePool value=dunes://service.dunes.ch/CustomSDKObject?id='tr01vpsvcntr002%2Cid:resgroup-320564'&dunesName='VC:ResourcePool'
| 'attribute': name=thinProvision type=boolean value=false
| 'attribute': name=vm type=VC:VirtualMachine value=dunes://service.dunes.ch/CustomSDKObject?id='tr01vpsvcntr002%2Cid:vm-519330'&dunesName='VC:VirtualMachine'
| 'attribute': name=ADOU type=AD:OrganizationalUnit value=dunes://service.dunes.ch/CustomSDKObject?id='%23_v2_%23%2C%23OU%23%2C%234506f67e-1d33-4e35-a5af-510ea148b5cb%23%2C%23OU%3DVR%20Orchestrator%2COU%3DUSFS%20Servers%2CDC%3Dshoremortgage%2CDC%3Dcom%23'&dunesName='AD:OrganizationalUnit'
| 'attribute': name=Domain type=string value=shoremortgage.com
| 'attribute': name=PSHost type=PowerShell:PowerShellHost value=dunes://service.dunes.ch/CustomSDKObject?id='407d66be-5db4-41c8-8fa6-94609e3fb5c4'&dunesName='PowerShell:PowerShellHost'
| 'input': name=name type=string value=vrotest004
| 'input': name=IP type=string value=10.8.6.100
| 'input': name=Mask type=string value=255.255.255.0
| 'input': name=Gateway type=string value=10.8.6.1
| 'input': name=username type=string value=myuseraccount
| 'output': name=newComputer type=AD:ComputerAD value=dunes://service.dunes.ch/CustomSDKObject?id='%23_v2_%23%2C%23Computer%23%2C%234506f67e-1d33-4e35-a5af-510ea148b5cb%23%2C%23CN%3Dvrotest004%2COU%3DVR%20Orchestrator%2COU%3DUSFS%20Servers%2CDC%3Dshoremortgage%2CDC%3Dcom%23'&dunesName='AD:ComputerAD'
*** End of execution stack.