Skip to content
This repository was archived by the owner on Dec 1, 2023. It is now read-only.

Commit 129b1ff

Browse files
committed
Testing to run commands in an elevated shell.
1 parent 6bb88c8 commit 129b1ff

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

.build.ps1

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,19 @@ task MoveLiveMountNetworkAddress {
191191
$output = Invoke-VMScript @splat -ErrorAction Stop
192192
Write-Verbose "Remote script output:`n$($output.ScriptOutput)" -Verbose
193193
$splat = @{
194-
ScriptText = '(Get-NetAdapter| where {($_.MacAddress).ToLower() -eq "' + $TestInterfaceMAC + '"} | Get-NetIPAddress -AddressFamily IPv4).IPAddress'
194+
ScriptText = 'function Elevate-Process {
195+
param ([string]$exe = $(Throw "Pleave provide the name and path of an executable"),[string]$arguments)
196+
$startinfo = new-object System.Diagnostics.ProcessStartInfo
197+
$startinfo.FileName = $exe
198+
$startinfo.Arguments = $arguments
199+
$startinfo.verb = "RunAs"
200+
$process = [System.Diagnostics.Process]::Start($startinfo)
201+
}
202+
function QueryIP {
203+
Get-NetAdapter| where {($_.MacAddress).ToLower() -eq "' + $TestInterfaceMAC + '"}
204+
| Get-NetIPAddress -AddressFamily IPv4).IPAddress
205+
}
206+
Elevate-Process -Exe powershell.exe -Arguments "-noninteractive -command QueryIP > C:\rubrik.txt"'
195207
ScriptType = 'PowerShell'
196208
VM = $Config.virtualMachines[$i].mountName
197209
GuestCredential = $GuestCredential

0 commit comments

Comments
 (0)