I am attempting to run a PowerCLI script to extend the Citrix D drive (WCDisk) 200+ VDI machines. Running the script in PowerCLI on a test machine works fine up until it hits the Invoke-VMScript
calling Diskpart.exe. It just hangs. I think I've determined when attempting to call Invoke-VMScript to run diskpart to extend D drive (WCDisk) within the VDI OS UAC is blocking it from running because it just hangs…See screen shot below.
Also, from within the VDI that the script is running against, I can see the Diskpart.exe CMD process just sitting there in TaskMgr.

Here is the test script I am running..
$HostCredential = Get-Credential
$GuestCredential = Get-Credential
#This part hangs
Invoke-VMScript -HostCredential $HostCredential -vm Win10Test6 -GuestCredential $GuestCredential -ScriptText "C:\windows\system32\diskpart.exe /s c:\Windows\temp\diskpart.txt" -ScriptType BAT
*** This stalls out ***
If I substitute the Diskpart commands for a non-interactive command such as 'dir' the process runs without issue. This tells me the process and my userid is not the issue.
This one works just fine so I know my userid is correct..
#Invoke-VMScript -HostCredential $HostCredential -vm Win10Test6 -GuestCredential $GuestCredential -ScriptText "dir"
*** Worked
NOTE:
• I ‘think’ UAC might be causing an issue but that is a hunch. I’ve tried to disable UAC but that takes a reboot to set the value and truly be
disabled. This is a Citrix PVS env and UAC is on and the VDI machines reboot to a known state (UAC on). I haven't gone as far as creating another image with UAC off to test.
Questions I need help with are:
- Is there a better or easier way to extend a drive via PS with UAC on?
- Is there a way to bypass UAC with use of Enter-PSSession running the same commands elevated?
Thank you for your help and time, Robert Jaudon