Skip navigation
John Savill'ss FAQs on IT Pro Today Hero

Savill's FAQs: Setting the $ Character in a PowerShell String

Three times a week, John Savill tackles your most pressing IT questions. Today, he shares about mixing the use of managed and unmanaged disks in Virtual Machines, using Add-AzureRmAccount and Login-AzureRmAccount, and how to set $ in a PowerShell string.

Three times a week (Monday/Wednesday/Friday), John Savill tackles your most pressing IT questions.

Read through the FAQ archives, or send him your questions via email.

Today, he shares about mixing the use of managed and unmanaged disks in Virtual Machines, using Add-AzureRmAccount and Login-AzureRmAccount, and how to set $ in a PowerShell string.


Q. Can I mix managed and unmanaged disks on a single VM?

A. No, a VM can only use one type of storage and you will receive an error if you attempt to mix types of storage. The error is:

"Addition of a blob based disk to VM with managed disks is not supported."

If you want to use managed disks on an existing VM, you can convert unmanaged disks to managed.

 

Q. Should I use Add-AzureRmAccount or Login-AzureRmAccount?

A. If you want Azure Resource Manager to manage resources, you must authenticate with an Azure AD account. There appear to be two cmdlets that do exactly the same thing: Add-AzureRmAccount and Login-AzureRmAccount so which should be used.

You can actually use either one as they are actually the same with Login-AzureRmAccount actually an alias to Add-AzureRmAccount which means when you use Login it is just redirecting to the Add cmdlet.

PS C:\> Get-Alias login-azurermaccount | fl

DisplayName       : Login-AzureRmAccount
CommandType       : Alias
Definition        : Add-AzureRmAccount
ReferencedCommand : Add-AzureRmAccount
ResolvedCommand   : Add-AzureRmAccount

 

Q. I am trying to set $ in a PowerShell string, how can I do this?

A. If you want to use the $ character in a PowerShell string, this is typically problematic since a $ signifies the start of a variable. Instead, escape the $ character by using the tick (`) character. I could use

"Pass`$word"

If I wanted Pass$word. Notice I am placing the term in double quotes as well.

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish