Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 在AWS中获取Windows实例ID_Python 3.x_Amazon Web Services_Amazon Ec2_Boto3 - Fatal编程技术网

Python 3.x 在AWS中获取Windows实例ID

Python 3.x 在AWS中获取Windows实例ID,python-3.x,amazon-web-services,amazon-ec2,boto3,Python 3.x,Amazon Web Services,Amazon Ec2,Boto3,您好,我正在AWS中运行Windows实例 但是,我希望使用powershell或python检索“实例id”。 我指的是这个 但我没法去上班 原因是我有这个数据库的所有实例ID,我需要检查数据库中的实例ID,并在不同的实例中执行一些代码,下面是伪代码 //check if the instane ID is in the DB if(instanece_id is in DB){ //perfore the action for that instance }else{ //print

您好,我正在AWS中运行Windows实例 但是,我希望使用powershell或python检索“实例id”。 我指的是这个

但我没法去上班

原因是我有这个数据库的所有实例ID,我需要检查数据库中的实例ID,并在不同的实例中执行一些代码,下面是伪代码

//check if the instane ID is in the DB
if(instanece_id is in DB){
 //perfore the action for that instance

}else{
 //print error message
}

我也尝试这样做:


但是没有返回任何结果

我试过这个,它有效,但它没有打印任何东西。你试过提供的示例,看看它们是否有效吗?如果它们有效,但您对
InstanceId
的命令无效,请编辑您的问题以显示您使用的命令。我成功了,我重新启动了一个实例,感谢上一个实例,我不知何故没有id
Get-EC2InstanceMetadata -Category AmiId
Get-EC2InstanceMetadata -Category InstanceId