PDT.psm1 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725
  1. #region localizeddata
  2. if (Test-Path "${PSScriptRoot}\${PSUICulture}")
  3. {
  4. Import-LocalizedData `
  5. -BindingVariable LocalizedData `
  6. -Filename PDT.strings.psd1 `
  7. -BaseDirectory "${PSScriptRoot}\${PSUICulture}"
  8. }
  9. else
  10. {
  11. #fallback to en-US
  12. Import-LocalizedData `
  13. -BindingVariable LocalizedData `
  14. -Filename PDT.strings.psd1 `
  15. -BaseDirectory "${PSScriptRoot}\en-US"
  16. }
  17. #endregion
  18. # Import the common certificate functions
  19. Import-Module -Name ( Join-Path `
  20. -Path (Split-Path -Path $PSScriptRoot -Parent) `
  21. -ChildPath 'CertificateCommon\CertificateCommon.psm1' )
  22. <#
  23. .SYNOPSIS
  24. Extracts an array of arguments that were found in the Arguments list passed in.
  25. It also optionally maps the arguments to a new name.
  26. .PARAMETER FunctionBoundParameters
  27. The parameters that were passed to the calling function.
  28. .PARAMETER ArgumentNames
  29. The array of arguments that should be extracted.
  30. .PARAMETER NewArgumentNames
  31. An array of argument names to rename each argument to.
  32. #>
  33. function Get-Arguments
  34. {
  35. [CmdletBinding()]
  36. param
  37. (
  38. [parameter(Mandatory = $true)]
  39. $FunctionBoundParameters,
  40. [parameter(Mandatory = $true)]
  41. [string[]] $ArgumentNames,
  42. [string[]] $NewArgumentNames
  43. )
  44. $returnValue=@{}
  45. for ($i=0;$i -lt $ArgumentNames.Count;$i++)
  46. {
  47. $argumentName = $ArgumentNames[$i]
  48. if ($NewArgumentNames -eq $null)
  49. {
  50. $newArgumentName = $argumentName
  51. }
  52. else
  53. {
  54. $newArgumentName = $NewArgumentNames[$i]
  55. }
  56. if ($FunctionBoundParameters.ContainsKey($argumentName))
  57. {
  58. $null = $returnValue.Add($NewArgumentName,$FunctionBoundParameters[$argumentName])
  59. }
  60. }
  61. return $returnValue
  62. } # end function Get-Arguments
  63. <#
  64. .SYNOPSIS
  65. Initialize the Win32 PInvoke wrapper.
  66. #>
  67. function Initialize-PInvoke
  68. {
  69. $script:ProgramSource = @"
  70. using System;
  71. using System.Collections.Generic;
  72. using System.Text;
  73. using System.Security;
  74. using System.Runtime.InteropServices;
  75. using System.Diagnostics;
  76. using System.Security.Principal;
  77. using System.ComponentModel;
  78. using System.IO;
  79. namespace Source
  80. {
  81. [SuppressUnmanagedCodeSecurity]
  82. public static class NativeMethods
  83. {
  84. //The following structs and enums are used by the various Win32 API's that are used in the code below
  85. [StructLayout(LayoutKind.Sequential)]
  86. public struct STARTUPINFO
  87. {
  88. public Int32 cb;
  89. public string lpReserved;
  90. public string lpDesktop;
  91. public string lpTitle;
  92. public Int32 dwX;
  93. public Int32 dwY;
  94. public Int32 dwXSize;
  95. public Int32 dwXCountChars;
  96. public Int32 dwYCountChars;
  97. public Int32 dwFillAttribute;
  98. public Int32 dwFlags;
  99. public Int16 wShowWindow;
  100. public Int16 cbReserved2;
  101. public IntPtr lpReserved2;
  102. public IntPtr hStdInput;
  103. public IntPtr hStdOutput;
  104. public IntPtr hStdError;
  105. }
  106. [StructLayout(LayoutKind.Sequential)]
  107. public struct PROCESS_INFORMATION
  108. {
  109. public IntPtr hProcess;
  110. public IntPtr hThread;
  111. public Int32 dwProcessID;
  112. public Int32 dwThreadID;
  113. }
  114. [Flags]
  115. public enum LogonType
  116. {
  117. LOGON32_LOGON_INTERACTIVE = 2,
  118. LOGON32_LOGON_NETWORK = 3,
  119. LOGON32_LOGON_BATCH = 4,
  120. LOGON32_LOGON_SERVICE = 5,
  121. LOGON32_LOGON_UNLOCK = 7,
  122. LOGON32_LOGON_NETWORK_CLEARTEXT = 8,
  123. LOGON32_LOGON_NEW_CREDENTIALS = 9
  124. }
  125. [Flags]
  126. public enum LogonProvider
  127. {
  128. LOGON32_PROVIDER_DEFAULT = 0,
  129. LOGON32_PROVIDER_WINNT35,
  130. LOGON32_PROVIDER_WINNT40,
  131. LOGON32_PROVIDER_WINNT50
  132. }
  133. [StructLayout(LayoutKind.Sequential)]
  134. public struct SECURITY_ATTRIBUTES
  135. {
  136. public Int32 Length;
  137. public IntPtr lpSecurityDescriptor;
  138. public bool bInheritHandle;
  139. }
  140. public enum SECURITY_IMPERSONATION_LEVEL
  141. {
  142. SecurityAnonymous,
  143. SecurityIdentification,
  144. SecurityImpersonation,
  145. SecurityDelegation
  146. }
  147. public enum TOKEN_TYPE
  148. {
  149. TokenPrimary = 1,
  150. TokenImpersonation
  151. }
  152. [StructLayout(LayoutKind.Sequential, Pack = 1)]
  153. internal struct TokPriv1Luid
  154. {
  155. public int Count;
  156. public long Luid;
  157. public int Attr;
  158. }
  159. public const int GENERIC_ALL_ACCESS = 0x10000000;
  160. public const int CREATE_NO_WINDOW = 0x08000000;
  161. internal const int SE_PRIVILEGE_ENABLED = 0x00000002;
  162. internal const int TOKEN_QUERY = 0x00000008;
  163. internal const int TOKEN_ADJUST_PRIVILEGES = 0x00000020;
  164. internal const string SE_INCRASE_QUOTA = "SeIncreaseQuotaPrivilege";
  165. [DllImport("kernel32.dll",
  166. EntryPoint = "CloseHandle", SetLastError = true,
  167. CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
  168. public static extern bool CloseHandle(IntPtr handle);
  169. [DllImport("advapi32.dll",
  170. EntryPoint = "CreateProcessAsUser", SetLastError = true,
  171. CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
  172. public static extern bool CreateProcessAsUser(
  173. IntPtr hToken,
  174. string lpApplicationName,
  175. string lpCommandLine,
  176. ref SECURITY_ATTRIBUTES lpProcessAttributes,
  177. ref SECURITY_ATTRIBUTES lpThreadAttributes,
  178. bool bInheritHandle,
  179. Int32 dwCreationFlags,
  180. IntPtr lpEnvrionment,
  181. string lpCurrentDirectory,
  182. ref STARTUPINFO lpStartupInfo,
  183. ref PROCESS_INFORMATION lpProcessInformation
  184. );
  185. [DllImport("advapi32.dll", EntryPoint = "DuplicateTokenEx")]
  186. public static extern bool DuplicateTokenEx(
  187. IntPtr hExistingToken,
  188. Int32 dwDesiredAccess,
  189. ref SECURITY_ATTRIBUTES lpThreadAttributes,
  190. Int32 ImpersonationLevel,
  191. Int32 dwTokenType,
  192. ref IntPtr phNewToken
  193. );
  194. [DllImport("advapi32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
  195. public static extern Boolean LogonUser(
  196. String lpszUserName,
  197. String lpszDomain,
  198. String lpszPassword,
  199. LogonType dwLogonType,
  200. LogonProvider dwLogonProvider,
  201. out IntPtr phToken
  202. );
  203. [DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)]
  204. internal static extern bool AdjustTokenPrivileges(
  205. IntPtr htok,
  206. bool disall,
  207. ref TokPriv1Luid newst,
  208. int len,
  209. IntPtr prev,
  210. IntPtr relen
  211. );
  212. [DllImport("kernel32.dll", ExactSpelling = true)]
  213. internal static extern IntPtr GetCurrentProcess();
  214. [DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)]
  215. internal static extern bool OpenProcessToken(
  216. IntPtr h,
  217. int acc,
  218. ref IntPtr phtok
  219. );
  220. [DllImport("advapi32.dll", SetLastError = true)]
  221. internal static extern bool LookupPrivilegeValue(
  222. string host,
  223. string name,
  224. ref long pluid
  225. );
  226. public static void CreateProcessAsUser(string strCommand, string strDomain, string strName, string strPassword)
  227. {
  228. var hToken = IntPtr.Zero;
  229. var hDupedToken = IntPtr.Zero;
  230. TokPriv1Luid tp;
  231. var pi = new PROCESS_INFORMATION();
  232. var sa = new SECURITY_ATTRIBUTES();
  233. sa.Length = Marshal.SizeOf(sa);
  234. Boolean bResult = false;
  235. try
  236. {
  237. bResult = LogonUser(
  238. strName,
  239. strDomain,
  240. strPassword,
  241. LogonType.LOGON32_LOGON_BATCH,
  242. LogonProvider.LOGON32_PROVIDER_DEFAULT,
  243. out hToken
  244. );
  245. if (!bResult)
  246. {
  247. throw new Win32Exception("The user could not be logged on. Ensure that the user has an existing profile on the machine and that correct credentials are provided. Logon error #" + Marshal.GetLastWin32Error().ToString());
  248. }
  249. IntPtr hproc = GetCurrentProcess();
  250. IntPtr htok = IntPtr.Zero;
  251. bResult = OpenProcessToken(
  252. hproc,
  253. TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
  254. ref htok
  255. );
  256. if(!bResult)
  257. {
  258. throw new Win32Exception("Open process token error #" + Marshal.GetLastWin32Error().ToString());
  259. }
  260. tp.Count = 1;
  261. tp.Luid = 0;
  262. tp.Attr = SE_PRIVILEGE_ENABLED;
  263. bResult = LookupPrivilegeValue(
  264. null,
  265. SE_INCRASE_QUOTA,
  266. ref tp.Luid
  267. );
  268. if(!bResult)
  269. {
  270. throw new Win32Exception("Error in looking up privilege of the process. This should not happen if DSC is running as LocalSystem Lookup privilege error #" + Marshal.GetLastWin32Error().ToString());
  271. }
  272. bResult = AdjustTokenPrivileges(
  273. htok,
  274. false,
  275. ref tp,
  276. 0,
  277. IntPtr.Zero,
  278. IntPtr.Zero
  279. );
  280. if(!bResult)
  281. {
  282. throw new Win32Exception("Token elevation error #" + Marshal.GetLastWin32Error().ToString());
  283. }
  284. bResult = DuplicateTokenEx(
  285. hToken,
  286. GENERIC_ALL_ACCESS,
  287. ref sa,
  288. (int)SECURITY_IMPERSONATION_LEVEL.SecurityIdentification,
  289. (int)TOKEN_TYPE.TokenPrimary,
  290. ref hDupedToken
  291. );
  292. if(!bResult)
  293. {
  294. throw new Win32Exception("Duplicate Token error #" + Marshal.GetLastWin32Error().ToString());
  295. }
  296. var si = new STARTUPINFO();
  297. si.cb = Marshal.SizeOf(si);
  298. si.lpDesktop = "";
  299. bResult = CreateProcessAsUser(
  300. hDupedToken,
  301. null,
  302. strCommand,
  303. ref sa,
  304. ref sa,
  305. false,
  306. 0,
  307. IntPtr.Zero,
  308. null,
  309. ref si,
  310. ref pi
  311. );
  312. if(!bResult)
  313. {
  314. throw new Win32Exception("The process could not be created. Create process as user error #" + Marshal.GetLastWin32Error().ToString());
  315. }
  316. }
  317. finally
  318. {
  319. if (pi.hThread != IntPtr.Zero)
  320. {
  321. CloseHandle(pi.hThread);
  322. }
  323. if (pi.hProcess != IntPtr.Zero)
  324. {
  325. CloseHandle(pi.hProcess);
  326. }
  327. if (hDupedToken != IntPtr.Zero)
  328. {
  329. CloseHandle(hDupedToken);
  330. }
  331. }
  332. }
  333. }
  334. }
  335. "@
  336. Add-Type -TypeDefinition $ProgramSource -ReferencedAssemblies "System.ServiceProcess"
  337. } # end function Initialize-PInvoke
  338. <#
  339. .SYNOPSIS
  340. Gets a Win32 process that matches the path, arguments and is user.
  341. .PARAMETER Path
  342. The path to the executable running the process.
  343. .PARAMETER Arguments
  344. The arguments of the running process to find.
  345. .PARAMETER Credential
  346. The credentials of the account that the process is running under.
  347. #>
  348. function Get-Win32Process
  349. {
  350. [CmdletBinding()]
  351. param
  352. (
  353. [parameter(Mandatory = $true)]
  354. [ValidateNotNullOrEmpty()]
  355. [String] $Path,
  356. [String] $Arguments,
  357. [PSCredential] $Credential
  358. )
  359. $fileName = [io.path]::GetFileNameWithoutExtension($Path)
  360. $getProcesses = @(Get-Process -Name $fileName -ErrorAction SilentlyContinue)
  361. $processes = foreach ($process in $GetProcesses)
  362. {
  363. if ($process.Path -ieq $Path)
  364. {
  365. try
  366. {
  367. [wmi]"Win32_Process.Handle='$($process.Id)'"
  368. }
  369. catch
  370. {
  371. }
  372. }
  373. }
  374. if ($PSBoundParameters.ContainsKey('Credential'))
  375. {
  376. $processes = $processes |
  377. Where-Object -FilterScript {
  378. (Get-Win32ProcessOwner $_) -eq $Credential.UserName
  379. }
  380. }
  381. if ($Arguments -eq $null)
  382. {
  383. $Arguments = ""
  384. }
  385. $processes = $processes |
  386. Where-Object -FilterScript {
  387. (Get-Win32ProcessArgumentsFromCommandLine $_.CommandLine) -eq $Arguments
  388. }
  389. return $processes
  390. } # end function Get-Win32Process
  391. <#
  392. .SYNOPSIS
  393. Returns the Owner of a Win32 Process.
  394. .PARAMETER Process
  395. The Win32 WMI process to get the owner for.
  396. #>
  397. function Get-Win32ProcessOwner
  398. {
  399. param
  400. (
  401. [parameter(Mandatory = $true)]
  402. [ValidateNotNull()]
  403. $Process
  404. )
  405. try
  406. {
  407. $owner = $Process.GetOwner()
  408. }
  409. catch
  410. {
  411. }
  412. if ($owner.Domain -ne $null)
  413. {
  414. return $owner.Domain + "\" + $owner.User
  415. }
  416. else
  417. {
  418. return $owner.User
  419. }
  420. } # end function Get-Win32ProcessOwner
  421. <#
  422. .SYNOPSIS
  423. Extracts the arguments from a complete command line
  424. .PARAMETER CommandLine
  425. The complete command line to extract the arguments from.
  426. #>
  427. function Get-Win32ProcessArgumentsFromCommandLine
  428. {
  429. param
  430. (
  431. [String] $CommandLine
  432. )
  433. if ($commandLine -eq $null)
  434. {
  435. return ""
  436. }
  437. $commandLine = $commandLine.Trim()
  438. if ($commandLine.Length -eq 0)
  439. {
  440. return ""
  441. }
  442. if ($commandLine[0] -eq '"')
  443. {
  444. $charToLookfor = [char]'"'
  445. }
  446. else
  447. {
  448. $charToLookfor = [char]' '
  449. }
  450. $endOfCommand = $commandLine.IndexOf($charToLookfor ,1)
  451. if ($endOfCommand -eq -1)
  452. {
  453. return ""
  454. }
  455. return $commandLine.Substring($endOfCommand+1).Trim()
  456. } # end funcion Get-Win32ProcessArgumentsFromCommandLine
  457. <#
  458. .SYNOPSIS
  459. Starts a Win32 Process using PInvoke.
  460. .PARAMETER Path
  461. The full path to the executable to start the process with.
  462. .PARAMETER Arguments
  463. The arguments to pass to the executable when starting the process.
  464. .PARAMETER Credential
  465. The user account to start the process under.
  466. #>
  467. function Start-Win32Process
  468. {
  469. param
  470. (
  471. [parameter(Mandatory = $true)]
  472. [ValidateNotNullOrEmpty()]
  473. [String] $Path,
  474. [String] $Arguments,
  475. [PSCredential] $Credential
  476. )
  477. $getArguments = Get-Arguments $PSBoundParameters ("Path","Arguments","Credential")
  478. $processes = @(Get-Win32Process @getArguments)
  479. if ($processes.Count -eq 0)
  480. {
  481. if($PSBoundParameters.ContainsKey("Credential"))
  482. {
  483. try
  484. {
  485. Initialize-PInvoke
  486. [Source.NativeMethods]::CreateProcessAsUser(`
  487. ("$Path " + $Arguments),`
  488. $Credential.GetNetworkCredential().Domain,`
  489. $Credential.GetNetworkCredential().UserName,`
  490. $Credential.GetNetworkCredential().Password)
  491. }
  492. catch
  493. {
  494. try
  495. {
  496. Initialize-PInvoke
  497. [Source.NativeMethods]::CreateProcessAsUser(`
  498. ("$Path " + $Arguments),`
  499. $Credential.GetNetworkCredential().Domain,`
  500. $Credential.GetNetworkCredential().UserName,`
  501. $Credential.GetNetworkCredential().Password)
  502. }
  503. catch
  504. {
  505. $exception = New-Object System.ArgumentException $_
  506. $errorCategory = [System.Management.Automation.ErrorCategory]::OperationStopped
  507. $errorRecord = New-Object -TypeName System.Management.Automation.ErrorRecord $exception, "Win32Exception", $errorCategory, $null
  508. $err = $errorRecord
  509. }
  510. }
  511. }
  512. else
  513. {
  514. $startArguments = Get-Arguments $PSBoundParameters `
  515. ("Path", "Arguments", "Credential") `
  516. ("FilePath", "ArgumentList", "Credential")
  517. if([string]::IsNullOrEmpty($Arguments))
  518. {
  519. $null = $startArguments.Remove("ArgumentList")
  520. }
  521. $err = Start-Process @StartArguments
  522. }
  523. if($err -ne $null)
  524. {
  525. throw $err
  526. }
  527. Wait-Win32ProcessStart @GetArguments
  528. }
  529. else
  530. {
  531. return ($LocalizedData.ProcessAlreadyStarted -f $Path,$processes.ProcessId)
  532. }
  533. $processes = @(Get-Win32Process @getArguments)
  534. return ($LocalizedData.ProcessStarted -f $Path,$processes.ProcessId)
  535. } # end function Start-Win32Process
  536. <#
  537. .SYNOPSIS
  538. Wait for a Win32 process to start.
  539. .PARAMETER Path
  540. The full path to the executable of the process to wait for.
  541. .PARAMETER Arguments
  542. The arguments passed to the executable of the process to wait for.
  543. .PARAMETER Credential
  544. The user account the process will be running under.
  545. .PARAMETER Timeout
  546. The milliseconds to wait for the process to start.
  547. #>
  548. function Wait-Win32ProcessStart
  549. {
  550. [CmdletBinding()]
  551. param
  552. (
  553. [parameter(Mandatory = $true)]
  554. [ValidateNotNullOrEmpty()]
  555. [String] $Path,
  556. [String] $Arguments,
  557. [PSCredential] $Credential,
  558. [Int] $Timeout = 5000
  559. )
  560. $start = [DateTime]::Now
  561. $getArguments = Get-Arguments $PSBoundParameters ("Path","Arguments","Credential")
  562. $started = (@(Get-Win32Process @GetArguments).Count -ge 1)
  563. While (-not $started -and ([DateTime]::Now - $start).TotalMilliseconds -lt $Timeout)
  564. {
  565. Start-Sleep -Seconds 1
  566. $started = @(Get-Win32Process @GetArguments).Count -ge 1
  567. }
  568. return $started
  569. } # end function Wait-Win32ProcessStart
  570. <#
  571. .SYNOPSIS
  572. Wait for a Win32 process to stop. This assumes the process was aleady confirmed to have been started by first
  573. calling Wait-Win32ProcessStart.
  574. .PARAMETER Path
  575. The full path to the executable of the process to wait for.
  576. .PARAMETER Arguments
  577. The arguments passed to the executable of the process to wait for.
  578. .PARAMETER Credential
  579. The user account the process will be running under.
  580. .PARAMETER Timeout
  581. The milliseconds to wait for the process to stop.
  582. #>
  583. function Wait-Win32ProcessStop
  584. {
  585. [CmdletBinding()]
  586. param
  587. (
  588. [parameter(Mandatory = $true)]
  589. [ValidateNotNullOrEmpty()]
  590. [String] $Path,
  591. [String] $Arguments,
  592. [PSCredential] $Credential,
  593. [Int] $Timeout = 30000
  594. )
  595. $start = [DateTime]::Now
  596. $getArguments = Get-Arguments $PSBoundParameters ("Path","Arguments","Credential")
  597. $stopped = (@(Get-Win32Process @GetArguments).Count -eq 0)
  598. While (-not $stopped -and ([DateTime]::Now - $start).TotalMilliseconds -lt $Timeout)
  599. {
  600. Start-Sleep -Seconds 1
  601. $stopped = (@(Get-Win32Process @GetArguments).Count -eq 0)
  602. }
  603. return $stopped
  604. } # end function Wait-Win32ProcessStop
  605. <#
  606. .SYNOPSIS
  607. Wait for a Win32 process to complete.
  608. .PARAMETER Path
  609. The full path to the executable of the process to wait for.
  610. .PARAMETER Arguments
  611. The arguments passed to the executable of the process to wait for.
  612. .PARAMETER Credential
  613. The user account the process will be running under.
  614. .PARAMETER Timeout
  615. The amount of time to wait for the process to end.
  616. #>
  617. function Wait-Win32ProcessEnd
  618. {
  619. [CmdletBinding()]
  620. param
  621. (
  622. [parameter(Mandatory = $true)]
  623. [ValidateNotNullOrEmpty()]
  624. [String] $Path,
  625. [String] $Arguments,
  626. [PSCredential] $Credential
  627. )
  628. $getArguments = Get-Arguments $PSBoundParameters ("Path","Arguments","Credential")
  629. # Wait for the process to start
  630. if (-not (Wait-Win32ProcessStart @getArguments))
  631. {
  632. New-InvalidArgumentError `
  633. -ErrorId 'ProcessFailedToStartError' `
  634. -ErrorMessage ($LocalizedData.ProcessFailedToStartError -f $Path,$Arguments)
  635. }
  636. if (-not (Wait-Win32ProcessStop @getArguments))
  637. {
  638. # The process did not stop.
  639. New-InvalidArgumentError `
  640. -ErrorId 'ProcessFailedToStopError' `
  641. -ErrorMessage ($LocalizedData.ProcessFailedToStopError -f $Path,$Arguments)
  642. }
  643. } # end function Wait-Win32ProcessEnd
  644. Export-ModuleMember Start-Win32Process,Wait-Win32ProcessStart,Wait-Win32ProcessStop,Wait-Win32ProcessEnd