Hi Suriya_Invisibl,
Have a nice day!
If you are using AWS or GCE command line tools (such as the AWS CLI or gcloud) and want to shut down instances through those tools, you should use the appropriate commands from those tools instead of running PowerShell scripts inside the instances.
For AWS, you can use the ec2 stop-instances command from the AWS CLI:
aws ec2 stop-instances --instance-ids i-1234567890abcdef0
For GCE, you can use the compute instances stop command from the gcloud CLI:
gcloud compute instances stop INSTANCE_NAME --zone=ZONE
Be sure to replace i-1234567890abcdef0 with your AWS instance ID, INSTANCE_NAME with your GCE instance name, and ZONE with the zone where the instance is located.
Best regards
Neuvi Jiang