Download A Few Files from Azure Blob Storage

Azure Blob Storage is a great and cheap place to upload a lot of files.

One of the websites I am currently work on, stores all the PDFs that users can download, in an Azure Blob Storage container.

We needed to pull down a large amount of those PDFs to confirm the content in them.

So I wrote the following PowerShell:

$LocalTargetDirectory = "D:\Temp\FilesDownloaded\"
$StorageAccountName = "YourStorageAccountName"
$StorageAccountKey = "YourStorageAccountKey"
$ContainerName = "YourContainerName"
$Blobs = @("file1","file2")

New-Item -Force -ItemType directory -Path $LocalTargetDirectory
$Context = New-AzureStorageContext -StorageAccountName $StorageAccountName -StorageAccountKey $StorageAccountKey

foreach($Blob in $Blobs)
{
Get-AzureStorageBlobContent -Blob $Blob -Container $ContainerName -Destination $LocalTargetDirectory -Context $Context
}

To get this to work for you, replace:
LocalTargetDirectory with where you want to download the files to.
StorageAccountName with the name of the Azure Storage Account Name.
StorageAccountKey with the name of the Azure Storage Account Key.
ContainerName with the container that you have the files saved in.
Blobs is an array of the files you want to download from the container.

NuGet- Failed to initialize the PowerShell host issues

I recently had issues updating some NuGet packages in my solution at work, it was giving me the following error:

“Failed to initialize the PowerShell host. If your PowerShell execution policy setting is set to AllSigned, open the Package Manager Console to initialize the host first.”

nuget fail

There is a really simple fix for this.

1.Click start and type in powershell.
2.Right click “Windows PowerShell (x86)” then click run as administrator
3.Type in: “Set-ExecutionPolicy Unrestricted” (without the quotes) and hit enter.

Finally restart Visual Studio and try adding that NuGet package again.

Easily see all members of an Active Directory Group

Recently I had an issue with SQL Server permissions and someone not being able to log into one of our development machines.

I knew that the instance had read access for everyone in a specific Active Directory Group. After trying to log in as the user and seeing the issue, I decided I better check if she was added to the group or not.

First thing I did was crack open the ever handy AD Explorer and found that searching for the group, (which took a long time in our environment) did not show me who was members.

I then remembered that there was a command line way to check the users.
So I clicked, Start, Run, typed in cmd.exe and in the command prompt  typed:
NET GROUP “group name here” /DOMAIN
net group
The output will show you the group name, the comment about the group and the members of it.