简体   繁体   中英

Azure Powershell ISE Execution query

I am using azure powershell ISE. I have a very long script to run where I am using variables to store data and further I am using them in my code. The problem is I am not able to run this script in a single go, reason being execution is not line by line. Sometimes it tries to execute a command before the variable is assigned its value. It throws an error.

I want to run 200 lines of code having 30 variables in a single go using powershell ISE. Eg. Problem is-

Get-azurevm -servicename $a -vmname $b

is getting executed before $a= xxx $b= yyy is getting initialized.I have initialized my variables before using but I guess execution fashion is not line by line.

What could be the possible solution for this?

Is there any option I can make the execution line by line ?

Azure PS execution is always line by line. If something like this is happening you can break the code into function and you can execute your desired code to execute only if the before ones codes have already been executed. It is always good to go with modules if u have a long code.

Also you can use-

start-sleep -s "no. of seconds to give other code to execute"

for execution of code which takes a bit longer time.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM