从PowerShell中删除OpenStack实例

从PowerShell中删除OpenStack实例,powershell,openstack,Powershell,Openstack,我已经编写了一个PowerShell脚本,它将从txt文件中获取InstanceID。它们采用此格式c5d1fa69-fe2d-4a5b-8446-5c9751429e48 我试图使用此ID删除实例,但无法正常工作 $instancesID = Get-Content C:\instance.txt foreach ($entry in $instancesID) { #Get rid of the white space from txt file $ID = $entry.

我已经编写了一个PowerShell脚本,它将从txt文件中获取InstanceID。它们采用此格式
c5d1fa69-fe2d-4a5b-8446-5c9751429e48

我试图使用此ID删除实例,但无法正常工作

$instancesID = Get-Content C:\instance.txt

foreach ($entry in $instancesID) {
    #Get rid of the white space from txt file
    $ID = $entry.Trim()
}
nova delete $ID
如果我为“c5d1fa69-fe2d-4a5b-8446-5c9751429e48”更改
$ID
,它工作正常

$instancesID = Get-Content C:\instance.txt

foreach ($entry in $instancesID) {
    #Get rid of the white space from txt file
    $ID = $entry.Trim()
}
nova delete $ID
如何从文本文件中获取ID,以便它执行如下命令:

nova delete c5d1fa69-fe2d-4a5b-8446-5c9751429e48
如前所述,您很可能只需要将
nova
命令行放入循环中:

foreach ($entry in $instancesID) {
    $ID = $entry.Trim()
    nova delete $ID
}
如前所述,您很可能只需要将
nova
命令行放入循环中:

foreach ($entry in $instancesID) {
    $ID = $entry.Trim()
    nova delete $ID
}

根据您的代码,反转最后两行,以便删除内容位于花括号内。根据您的代码,反转最后两行,以便删除内容位于花括号内。