Showing posts with label select. Show all posts
Showing posts with label select. Show all posts

Thursday, March 6, 2014

Part-3: Azure and PowerShell: Create a New Website on Windows Azure using PowerShell.

 

Part-1 : Getting Started With Windows Azure And PowerShell

Part-2: Connect To Windows Azure Using PowerShell

 

Hi, in my previous post, I had shown to you how to connect with “Windows Azure” using “PowerShell”.

Now, it’s time to “Do” and create something.

What about creating a website?

Nice idea! Isn’t!

Let’s get started.

In my Azure web portal you can see, currently I have no website.

clip_image002

 

Before open and start working on our “PowerShell” console, let’s have a quick look on what are the options those are required to create a website using Windows Azure web portal.

 

clip_image004

 

You can see in above picture, when we are creating a new website using “Quick Create” option in “Windows Azure” it is asking for provide  “URL” name and select a “Region”.

That’s fine. Let’s do it in our “PowerShell” way.

Open PowerShell console.

First, to get the list of geographical locations, we can use the “Get-AzureLocation” cmdlet. 

 

Run “Get-AzureLocation” cmdlet and pipe the output to “Select-Object” and choose Name property to select.

 

Get-AzureLocation | Select Name

 

Now we know which “Location” name has to use while creating a website. I live in India, to me it seems the “Southeast Asia” is a proper option.

clip_image005

 

Now the next step is to create a website.

For creating a website, use “New-AzureWebsite” cmdlet.

We are creating a website, using location “Southeast Asia’” and with a website name ‘ADhally’. 

New-AzureWebsite -Location ‘Southeast Asia’ -Name ‘ADhally’ 

 

clip_image007

 

When I run the above command, it throw the “EndpoingNotFoundException” error. I was wondering why it is not able to find endpoint.

To solve my curiosity, I checked the geographical locations available while creating website in the Azure web portal. And you can see there are no option of “SouthEast Asia” is listed.

clip_image008 

 

Ohk!

Now for me the closest option to “Southeast Asia” seems to be “East Asia” {because it has Asia word in it !! HA HA !) , let’s try that.

New-AzureWebsite -Location "East Asia" -Name "ADhally" 

 

It work well as expected, without throwing any error.

 

clip_image010

 

In hostname property it has given us the URL link to our newly created website.

Now’ let’s try opening a website which we have just created adhally.azurewebsites.net

 

clip_image012

 

Here you go, website is created successfully.

On our Azure web portal you able to see this newly website too J

 

clip_image014

 

To get the list of all of your website using PowerShell, you can use the “Get-AzureWebsite” cmdlet.

 

clip_image015

 

How to Video

Create a Website on Windows Azure using PowerShell.

 

That’s all for now J  see you in my next blog post.

Regards

Aman

clip_image017 clip_image018 clip_image019 clip_image020  clip_image021

 

Thursday, August 16, 2012

Powershell & active directory : Find all AD users account those are created between predefined period of time.

Hi,

Reporting,Monitoring and the Documentation are few of the major tasks which most of the IT admin does like me. If you know how to do scripting it saves lots of time. For all IT guys those primarily works on Windows Platform for them i think learning of Powershell is must, because if you know Powershell you can automate or script most of the daily to daily tasks. 

Powershell is like  Swiss Army knife.

My todays task was to create a list of all active directory users account those are created within a week. It is easy but worth sharing.

Make sure you have RSAT tools installed before running the Active Directory based cmdlets.

Today is 16 August and i want to find a users those are create within a week so if we minus 7 days we got 9 August, so we want to know how many users created with-in the time period of 9th - 16 August.

Lets Start.

First we need to import Active Directory module.

Import-Module -Name ActiveDirectory 

300420122321033


Now we need to define date. The date will be sever days earlier, this is easy we just need to minus 7 days from the current date. Get-Date support a method .AddDays by which you can add or minus days.

$week = (Get-Date).AddDays(-7)

when you run the $week variable we can get a 7 days earlier date.


16-08-2012 18-58-11


Good. Now our next step is to find users. Now we are going to use Get-ADUser , and then using -Filter * to search and find all users, and we are using -Properties * so that it expand all properties of the user, and then we are piping the output to where cmdlet and then are are choosing only those users from the output who’s $_.whenCreated property is greater then or Equal to $week.

Get-ADUser -Filter * -Properties * | where { $_.whenCreated -ge $week }


We have the output now., but lets format a more little bit.


16-08-2012 19-02-03


let add more one more pipe to the command, pipe it to select Cmdlet and choose to show only, Name and When Created Property.

Get-ADUser -Filter * -Properties * | where { $_.whenCreated -ge $week } | select Name,whenCreated

Not is looks nice isn’t ?


16-08-2012 19-15-39


Powershell Script for this.



To make this task more easy , i have create a powershell script which can do this task, and the script with export all the users Name, When created to a CSV file and save that on your Desktop.


You can download the script from this link : https://dl.dropbox.com/u/17858935/AD_Users_Created_WithIn_Predifined_Perios.zip 


Thanks

Aman Dhally

join aman on facebook Join aman on Linkedin follow aman on Twitter

Friday, June 15, 2012

Powershell and Active Directory: Find Active Directory users in a particular Organizational Unit whose Script Path is not set or blank using Powershell.

 

Hi,

If we are using "Active Directory" then one this is sure that 98% we are using some login scripts. Sometime while creating users we forget to mentioned to specify the login script in account.

15-06-2012 12-43-37

My task of today is to find all users accounts those have no login script defined in their accounts.

Let's Start.

 Make sure you have "RSAT" installed on you laptop.

Now Import the Active Directory module.

Import-Module ActiveDirectory

30-04-2012 23-21-03 

..

ok, Module is imported,

...

I want to search a particular organizational unit for users. I am not so good in LDAP so i always do a trick to find full path of OU.

Find OU.

I know a user name "Will smith" in located in that Organizational unit on whom i want to search users those have blank LOGIN SCRIPT field.

I run Get-ADUser cmdlet against Will.smith and i choose to show me of DistinguishedName the user. That DistinguishedName name contain full path of that OU

(Get-ADUser will.smith).DistinguishedName

Copy all fields expect CN and saved it to a variable.

15-06-2012 12-44-57 

$ou = "OU=testing,DC=localDC,DC=com"

15-06-2012 12-55-32

We are using  Get-ADUser cmdlet , to the information about active Directory users, in -SearchBase we are telling it to search our  predefined Organizational Unit in $ou variable,   then -Filter * to search for all users , and then -Properties * to show all the properties of the user account , then we are piping the command to  where cmdlet and we are choosing to choose only those users whose SCRIPTPATH is equal to null or blank and after that we are selecting only names using select cmdlet.

Get-ADUser -SearchBase $ou -Filter * -Properties * | where { $_.ScriptPath -eq $null } | select Name

15-06-2012 12-59-34

All Done...Job is secured | once again ...

Thanks!

Aman Dhally

Buy-More-Twitter-Followers   4fb29548b6adc

dance_goofy

Wednesday, June 13, 2012

Powershell and Active Directory: Find all Active Directory users whose CITY property field in blank.

 

Hi,

Me again , yes yes i know , now you are going to ask me ,,"Aman" what is your task for the day",, ok ok telling you..Today my manager told me to find all  active directory users which don't have the CITY field set or those users whose CITY field is blank in there user properties.

I know that Active Directory Module has a Cmdlet to find users which is : Get-ADUser

 

Let's Start.

 Make sure you have "RSAT" installed on you laptop.

Now Import the Active Directory module.

Import-Module ActiveDirectory

30-04-2012 23-21-03 

..

ok, Module is imported,

To find all users in AD we need to user -Filter * and to get there all properties we need to use -Properties * parameters.

Get-ADUser -Filter * -Properties *

13-06-2012 12-02-27

but our target it to find CITY field which is blank., let's use Where-Object cmdlet to do this.

In this command we are asking powershell to Find all users with all of there properties and then then show is only those users whose CITY property is $null or blank.

Get-ADUser -Filter * -Properties * | Where-Object { $_.City -eq $null}

this is showing us huge amount of data.

13-06-2012 12-07-13

Lets just select names of the users only.

Get-ADUser -Filter * -Properties * | Where-Object { $_.City -eq $null} | Select Name

13-06-2012 12-09-21 

Wow !! i have the names of all users whose City filed in blank.. i can export it to CSV files and sent to my Manager :)

Thanks for reading

Thanks!

Aman Dhally

Buy-More-Twitter-Followers   4fb29548b6adc

penguin

Tuesday, June 12, 2012

Powershell and Active Directory: Find all organizational unit containers [OU] in Active Directory using Powershell.

 

Hi,

These days i think i am only and only working with Active Directory.  My Manager give me the task to show him the all Organizational Unit Container , so that we can re-arrange them and remove the OU those are not required any longer.

Seriously i don't know any way to do this. I never heard about it and never tried it before. Why ? my manager needs it ? that the first thought came in my mind, but buddy manager is a manager ;o) , i have to do it what he said.

The again i decide lets explore some Active Directory cmdlets and see if it have something.

In first attempt i found a single cmdlet which is able to do this. That is  Get-ADOrganizationalUnit

Let's Start.

 Make sure you have "RSAT" installed on you laptop.

Now Import the Active Directory module.

Import-Module ActiveDirectory

30-04-2012 23-21-03 

..

ok, Module is imported,

...

First run the to view all OUs run the single cmdlet with -Filter * parameters

Get-ADOrganizationalUnit -Filter *

It is showing us the details of all OUs.

New Delhi Powershell User Group

But i am still not satisfy with the result. let it filter more ,,

Get-ADOrganizationalUnit -Filter * | Select Name

I tried to select Name but the output is not so good. Because we can see Name but for example in below screenshot i have multiple OU container named as Users

12-06-2012 11-35-36

ok...still not happy.

let run another command

Get-ADOrganizationalUnit -Filter *  -properties * | Select CanonicalName

This command will show is a full path of our OUs.

12-06-2012 11-38-05

All Done :)

My Target of the day i achieved. Now can do facebook ;o) ;o)

Thanks for reading

Thanks!

Aman Dhally

Buy-More-Twitter-Followers   4fb29548b6adc

simba