-
Notifications
You must be signed in to change notification settings - Fork 7
/
Import-IPAProcess.ps1
83 lines (73 loc) · 2.2 KB
/
Import-IPAProcess.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<#
# AUTHOR : Pierrick Lozach
#>
function Import-IPAProcess() # {{{2
{
# Documentation {{{3
<#
.SYNOPSIS
Imports an IPA process
.DESCRIPTION
Imports an IPA process that is stored in a file
.PARAMETER ICSession
The Interaction Center Session
.PARAMETER Password
The password to the logged in user
.PARAMETER Path
The path to the IPA process to import
.PARAMETER Publish
Set to yes to publish the imported process. Default value is yes.
#> # }}}3
[CmdletBinding()]
Param(
[Parameter(Mandatory=$true)] [Alias("Session", "Id")] [ININ.ICSession] $ICSession,
[Parameter(Mandatory=$true)] [string] $Password,
[Parameter(Mandatory=$true)] [string] $Path,
[Parameter(Mandatory=$false)] [boolean] $Publish
)
# Get path to i3\ic\server directory
$cicPath = (Get-ItemProperty -LiteralPath "HKLM:\SOFTWARE\Wow6432Node\Interactive Intelligence").Target
# Set arguments
$filename = "$($cicPath)FlowUtil.exe"
$arguments = "/user=$($ICSession.user.id) /password=$($Password) /server=$($ICSession.server) /import=`"$($Path)`""
# Add publish flag
if ([string]::IsNullOrEmpty($Publish) -or $Publish) {
$arguments += " /publish"
}
# Create process object
$process = New-Object System.Diagnostics.Process
$process.StartInfo.FileName = $filename
$process.StartInfo.Arguments = $arguments
$process.StartInfo.UseShellExecute = $false
$process.StartInfo.RedirectStandardOutput = $true
$process.StartInfo.RedirectStandardError = $true
# Start the process & Format output
if ($process.Start()) {
$error = $process.StandardError.ReadToEnd()
if ($error) {
Write-Error $error
return
}
$output = $process.StandardOutput.ReadToEnd() -replace "\r\n$", ""
if ($output) {
if ($output.Contains("`r`n")) {
$output -split "`r`n"
}
elseif ($output.Contains("`n")) {
$output -split "`n"
}
else {
$output
}
}
}
# Wait until the process ends and get Exit Code
$process.WaitForExit()
& "$Env:SystemRoot\system32\cmd.exe" /c exit $process.ExitCode
$response = @{
"Output" = $output
"ExitCode" = $process.ExitCode
}
Write-Output $response | Format-Table
[PSCustomObject] $response
} # }}}2