Next Topic

Previous Topic

Book Contents

Sample Script: TLuaPowershell

--executes a Powershell command string

bExitStatus = false
PS = TLuaPowershell()
bStatus = PS:Open(5985, false)

if bStatus == true then
	sCmd = "Get-Date\n"
	bExec = PS:ExecuteCommand(sCmd)
	if bExec == true then
		sStatus = PS:GetStdOut()
		bExitStatus = true
	else
		sStatus = "Execute failed. " .. PS:GetStdErr()
	end
else
	sStatus = "Failed to open connection. "  .. PS:GetErrorDescription()
end

SetExitStatus(sStatus, bExitStatus)