powershell string change text to lowercase

Kelly Garcia
Kelly Garcia used Ask the Experts™
on
Hi All,

I have this line of code:
$ServiceBusRuleId = (Get-AzureRmEventHubAuthorizationRule -ResourceGroupName "poc-eventhub" -Namespace "poc-eventhub-defra").id 

Open in new window


this returns the following value:

$ServiceBusRuleId = /subscriptions/c7c95a-30-4ef4-bfa4-49107461/resourceps/p-eventhub/providers/Microsoft.EventHub/namespaces/p-eventhub-kay/AuthorizationRules/RootManageSharedAccessKey

Open in new window


i need it to convert the AuthorizationRules into lowercase . what is the best way to achieve this?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2018
Distinguished Expert 2018

Commented:
$ServiceBusRuleId = (Get-AzureRmEventHubAuthorizationRule -ResourceGroupName "poc-eventhub" -Namespace "poc-eventhub-defra").id
$lowerServiceBusRuleId = "$($ServiceBusRuleId)".ToLower()

Open in new window

The double quotes around the variable make sure it's actually a string; can't test it at the moment.
$ServiceBusRuleId.ToLower()
will work as well if the value returned is already a string.
Kelly GarciaSenior Systems Administrator

Author

Commented:
Hi,

thank you for your feedback, problem with this that it will make everything lowercase and this string is case sensitive, i only want the authorisationid to be lowercase.

Regards,
Kay
Most Valuable Expert 2018
Distinguished Expert 2018
Commented:
Sorry, missed that.
$ServiceBusRuleId = (Get-AzureRmEventHubAuthorizationRule -ResourceGroupName "poc-eventhub" -Namespace "poc-eventhub-defra").id
$lowerServiceBusRuleId = "$($ServiceBusRuleId)" -replace '/AuthorizationRules/', '/authorizationrules/'

Open in new window

Kelly GarciaSenior Systems Administrator

Author

Commented:
thank you!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial