所以我有一个主机名数组,我想在 45 主机上运行命令“Shutdown-VMGuest”。我想一次关闭 20 次,但是当我完成 40 次时却错过了最后 5 次。这是下面的代码,有人知道我做错了什么吗?
[System.Collections.ArrayList]$currentStartList = @()
$i=0
foreach ($vmHost in $PowerOffList){
$i++
[void]$currentstartList.Add($vmHost)
if ($i -gt "19"){
$vmToPowerOff = Get-VM -Name $currentstartList
$Confirmation= Read-Host "`n Do you want to hard powerdown the following VMs (y/n)? $currentstartList"
if ($Confirmation -eq 'y'){
Write-Output "`n Trying to power down VMs safely: $vmToPowerOff"
try {
Shutdown-VMGuest $vmToPowerOff
}
catch {
Write-Output "`n $vmToPowerOff has failed to power off safely"
$FailedVMs.Add($vmToPowerOff)
}
#clear lists
[System.Collections.ArrayList]$currentstartList = @()
$i=0
sleep …
Run Code Online (Sandbox Code Playgroud) 我有一个excel文件,我想把它转换成一个JSON
文件。所以excel是这样的:
-------------------------
| Col A | Col C | Col F |
--------+-------+--------
| 1 | A | EE |
| 2 | B | FF |
| 4 | C | FF |
| 5 | D | HH |
| 6 | D | HH |
| 7 | A | EE |
| 8 | E | EE |
--------------------------
Run Code Online (Sandbox Code Playgroud)
我希望JSON
遵循以下格式:
{
"EE": {
"A": {
"Col A key": "1",
"Col A key": …
Run Code Online (Sandbox Code Playgroud)