Forum Discussion
TWest1150
Jul 21, 2020Copper Contributor
How to change blob content type using powershell script
Hi, I'm trying to use the following script to change the content type of multiple blob storage files. I would like to add multiple blob.names so the script can update the content type of select ...
federicodls
Feb 18, 2022Copper Contributor
Hi TWest1150.
I used your post to create my own script and wrote all in one line. Of course, you have to create the Context as you have done.
Get-AzStorageBlob -Container $containerName -Blob "*" -Context $context | foreach { $_.ICloudBlob.Properties.ContentType = 'text/html'; $_.ICloudBlob.SetProperties() }
I ran this from a Cloud Shell window in the Azure Portal against 6000 files and finished in just a few minutes.
You asked this far ago, but this is one of the first results searching and hope this helps someone else.
Regards.
I used your post to create my own script and wrote all in one line. Of course, you have to create the Context as you have done.
Get-AzStorageBlob -Container $containerName -Blob "*" -Context $context | foreach { $_.ICloudBlob.Properties.ContentType = 'text/html'; $_.ICloudBlob.SetProperties() }
I ran this from a Cloud Shell window in the Azure Portal against 6000 files and finished in just a few minutes.
You asked this far ago, but this is one of the first results searching and hope this helps someone else.
Regards.