PowerShell Command for Azure not running as expected

I am trying to install a custom VM into Azure using the manufacturer's instructions. I have imported the AzurePublishSettingsFile and logged onto Azure.  When I follow the next set of instructions I get errors:

PS C:\WINDOWS\system32> $sub = get-azuresubscription
PS C:\WINDOWS\system32> $sub = get-azuresubscription -extendeddetails
PS C:\WINDOWS\system32> select-azuresubscription -subscriptionid $sub.subscriptionid -current
Select-AzureSubscription : Cannot convert 'System.Object[]' to the type 'System.String' required by parameter
'SubscriptionId'. Specified method is not supported.
At line:1 char:42
+ select-azuresubscription -subscriptionid $sub.subscriptionid -current
+                                          ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Select-AzureSubscription], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgument,Microsoft.WindowsAzure.Commands.Profile.SelectAzureSubscriptionCom
   mand

I know very little about PowerShell, I only follow the directions when they are called for. I know enough to know that an object and a string are different things but I don't know how to approach fixing it. Any help would be appreciated.
jconklin-ansinc-netAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

footechCommented:
In this case, the cmdlet Get-AzureSubscription must be returning multiple subscriptions, so $sub is an array.  You will need to pick the correct one.
You can run a command like $sub.count to see how many there are.  Run $sub to see all that are stored in the variable - they will be listed in order, starting the count from 0.  You can return just a particular one by running $sub[1] (replace 1 with the number of the item in the array).

Another method that can be used:
$sub = get-azuresubscription -extendeddetails | Out-GridView -OutputMode Single
A window will pop up with all the subscriptions.  You just need to select the right one, and then click OK.  The one you selected will be stored in the $sub variable, and the rest of your commands should work without modification.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jconklin-ansinc-netAuthor Commented:
That was it! I used the number in the command and it gave no errors.
select-azuresubscription -subscriptionid $sub[0].subscriptionid -current
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.