Month: October 2017


Select Azure Subscription to work with


When you have a larger organisation, you will have several Azure Subscriptions to work against. So here is how you switch.

1. Open Powershell

2. Type in: Add-AzureRmAccount​
(in pop-up enter admin id and password)

3. It will list up the subscription you are connected to when you have authenticated


4. Type in: Get-AzureRmSubscription
(will list out all your subscriptions)

5. Find the Subscription you want to connect to

6. Type in: Select-AzureRmSubscription -SubscriptionId “ENTER THE SUBSCRIPTION ID”

You can choose SubscriptionName too, but I prefere SubscriptionID


Count directory Objects in Active Directory


Some times you need to find out how many directory Objects you have in your AD.
A quick way of getting this done is to use the following PowerShell​ string

​​Get-ADObject -Filter {name -like ‘*’} -SearchBase ‘CN=Schema,CN=Configuration,DC=sameie,DC=COM’ -ResultSetSize $null | Measure-Object >c:\tmp\object_dump.txt

This will dump the information into a easy to read text file

object_count_output.PNG

Now you know how many Objects you have.


No more download 1 GB Test files


Tired of looking on the web for a big test file, or creating your own locally?
Then this is perfect for you too 🙂
Open CMD in administrator mode
Run the following command:
fsutil file createnew <file> <size in bytes>
F.eks this will create a 10 GB file in my tmp folder:
fsutil file createnew c:\tmp\10gb.test 10737418240
The key is to input the size of the file in bytes so here are some common file sizes to save you from math:
1 MB = 1048576 bytes
100 MB = 104857600 bytes
1 GB = 1073741824 bytes
10 GB = 10737418240 bytes
100 GB =107374182400 bytes
1 TB = 1099511627776 bytes
10 TB =10995116277760 bytes

Can’t Create Resources in Resource Group


I created a resource group and gave my colleague the contributor access to the resources group.

Then he was going to deploy Logic App, but got an error that he does not have access and is not authorized. So he tried to deploy a VM, same issue.
I deployed Logic App for him (not problem).

The error he gets looks like this:
Resource creation fails with the error which looks like below- Registering the resource providers has failed. Additional details from the underlying API that might be helpful: ‘AuthorizationFailed’ – The client xxx@xxx.com’ with object id ‘af648edh-5336-sf55-ff2f-14873afdc259’ does not have authorization to perform action ‘Microsoft.Compute/register/action’ over scope ‘/subscriptions/245455vgd4-34gg-afe4-975f-3345gdgs34s’. (Code: AuthorizationFailed)

Hmmmm….. What’s going on here?

With the contributor access to a resource group, you can create a resource e.g. a VM or Logic App. What went wrong here if we look at the error message and focus on ‘Microsoft.Compute/register/action’ over scope ‘/subscriptions/245455vgd4-34gg-afe4-975f-3345gdgs34s’. is that he is not authorized to create a resource, it is the authorization error to register a resource provider. So how do we solve it?

Well after a bit of Googling if found a solution that worked for me,

  • ​Log into Azure with an identity which has a subscription level access to register a resource provider e.g. admin/owner.
  •  Using PowerShell (PoSh) register the resource providers you need at the subscription level. You can also see which providers are available and registered already.

Open Powershell and enter the following:

– Login-AzureRmAccount

#List out all Subscriptions you have access to
– Get-AzureRmSubscription

– $subscriptionId= “<Subscription Id>”

– Select-AzureRmSubscription -SubscriptionId $subscriptionId

 
#List all available providers and register them
– Get-AzureRmResourceProvider -ListAvailable | Register-AzureRmResourceProvider -Force​​
*****UPDATE****
with the “new” AZ Module, you can now run this command:
Get-AzResourceProvider -ListAvailable | Register-AzResourceProvider

Hello world!


Welcome to WordPress. This is your first post. Edit or delete it, then start writing!