使用Powershell Azure模块,是否可以获取活动的订阅ID?
我可以使用db
设置订阅,但是import csv
def boo():
stock = input("Enter Stock #: ") # Generate data for each column to fill in to the output file.
VIN = input("Enter Full VIN: ") # Each line asks the user to add data do the line.
make = input("Enter Make: ")
model = input("Enter Model: ")
year = input("Enter Year: ")
l8v = input("Enter L8V: ")
print(stock, VIN, make, model, year, l8v) # Prints the line of user data
input4 = input(
"Append to inventory list? Y/N || anything else to exit") # Asks user to append the data to the output file.
if input4 == "Y" or input4 == "y":
with open('INV.csv', 'a',
newline='') as outfile: # Pull up a separate csv to write to, an output for collected data
w = csv.writer(outfile)
w.writerow([stock, VIN, make, model, year,
l8v]) # Need to write the previously pulled up line to new csv
print("INVENTORY UPDATED")
user_input = input('Do you want to add one more entry: Enter [Y/N]')
if user_input.lower() == 'y':
boo()
else:
exit()
boo()
返回的订阅名称没有特定的Set-AzContext
列
Get-AzContext
返回订阅列表,但不返回活动订阅。
答案 0 :(得分:2)
您可以使用以下命令执行此操作:
(Get-AzContext).Subscription.id