小编Gav*_*lyn的帖子

试图创造.初始化和格式化VHD磁盘

一些背景知识:我在实验室环境中工作,并且遇到了许多需要创建VHD并附加到VM进行压力测试的问题.我想出了一个脚本,允许用户使过程尽可能简单,如下所示:

$vms=Get-VM
$val = 0

Write-Host "This script is set up for quickly creating and initilizing VHDs"
$Path = Read-Host "Please enter the path you want to create the drives to. Use the formate in this example <E:\VHDS\>"
$fileName = Read-Host "The Drive will be <target>-<number>.vhdx.  Please Name the target "

$vhdSize = 1GB
$vmAmount = Read-Host "How many Drives should be attached to each VM?"

foreach ($vm in $vms)
{
    $n = $vm.Name

    while ($val -ne $vmAmount)
    {
        $vhdPath …
Run Code Online (Sandbox Code Playgroud)

powershell cmdlets vhd hyper-v

5
推荐指数
1
解决办法
3275
查看次数

在do ... while中将相关表达式匹配设置为false

我正在尝试编写一些非常基本的代码,但我也在正则表达式上挑战自己.我已经能够将代码混淆到一定程度,但我真正遇到问题的是我正在尝试运行do ... while循环而表达式为false.在这个时间点我绝对没有错误,但是do ... while循环继续运行.

我在下面附上相关代码,这里希望它有所帮助.

先感谢您

if (tollResponse == "yes")
{
    Console.WriteLine("How much do you pay per trip?");
    string tollTax = Console.ReadLine();
    Match toll = Regex.Match (tollTax, @"[\d .]+");

    if (toll.Success)
    {
        Math.Round(Convert.ToDecimal(tollTax), 2);
        Console.WriteLine("Good lord that's high... well it's your money");
    }
    else
    {
        do
        {
            Console.WriteLine("Please enter a proper number");
            tollTax = Console.ReadLine();
        }
        while (toll.Success == false);
    }
}
Run Code Online (Sandbox Code Playgroud)

c# regex pattern-matching do-while

2
推荐指数
1
解决办法
85
查看次数

标签 统计

c# ×1

cmdlets ×1

do-while ×1

hyper-v ×1

pattern-matching ×1

powershell ×1

regex ×1

vhd ×1