I have Powershell script that has below code
$instance_id=(Invoke-WebRequest -URI http://169.254.169.254/latest/meta-data/instance-id)
Write $_ "webrequest command output = " $instance_id >> C:/auto_register.log
$instance_id=$instance_id.Content
Write "instance_id is " $instance_id >> C:/auto_register.log
and output of the text file is
webrequest command output =
instance_id is
I have setup scheduled task to run this script on startup. When I execute this script manually in powershell then variable value gets set. However, It doesn't set value when I execute this script through TaskScheduler.
Does anybody know why?