I need to delete a partition from a particular hard drive on a virtual computer. I can do this manually, one computer at a time, with no problem. However, I need to be able to run a PowerShell script that will read a text file containing a list of computers and have the script iterate through each computer and remove that particular partition.
I know what the disk number and partition number is for each machine so there isn't a need for an "if" statement. I also know that the machines have this particular partition to be removed.
The script I am trying to use is below. When I run it in debugger all of the script is read except for the "Get-Partition" line. The script iterates through the computer list but doesn't pick up the partitions and therefore doesn't select the one I need to have deleted.
I have researched Google for various keywords relevant to getting the information I need but I can't find anything that addresses this problem specifically. Any suggestions or assistance with this is greatly appreciated.
I connect to the server that hosts the machines via a PowerCLI code command. The code is below:
$computers = Get-Content -Path C:\Temp\computers.txtforeach ($computer in $computers){ Get-Disk Get-Partition Remove-Partition -DiskNumber 0 -PartitionNumber 3}