Tuesday, January 15, 2013

Powershell and Active Directory: Finding User whose password is Expired.

Hi,

Yesterday i have got a call from my remote user, she is  saying that she is not able to login to the Intranet System and Outlook, I asked her if she has got any notifications about password failed (Setting using Group Policies). and she denied.

i said “OK”..

Somehow i feel this is related to her password, i thought let’s see if her password is expired or not.

The best way to check this is using “Powershell”

I opened my Powershell Console.

I imported my ActiveDirectory Module ( Import-Module ActiveDirectory )

and i shoot the command line.

Get-ADUser UserName -Properties *

14-01-2013 13-00-55

and when i scrolled down and i  seen “PasswordExpired : True

14-01-2013 13-00-19

and i call that lady over the phone and  told her to change her password.

You can also use this command line to find all users those password are expired.

Get-ADUser -Filter 'PasswordExpired -eq $true'

All Sorted… and i live “happily ever after” (till the second problem hit me Winking smile)

I love Powershell.

Thanks

Aman Dhally

 

clip_image001 clip_image002 clip_image003 clip_image005 clip_image007

Monday, January 7, 2013

Uninstalling Windows Features using Powershell V3

Hi,

In my previous post i posted about on “How to install windows features” using powershell v3. Today i am about to post about how to un-install them.

The un-installation of windows features using powershell quite easy as installing them.

Let’s start.

Lets check if we still have “XPS-Viewer” installed as feature on our windows 8 server machine.,

Get-WindowsFeature -Name "XPS-Viewer"

So XPS-Viewer is still installed.

07-01-2013 15-53-30

Now lets uninstall it using the cmdlet “Uninstall-WindowsFeature”

run  Uninstall-WindowsFeature” with -Name parameter and provide the name of the windows feature which you want to uninstall.

Uninstall-WindowsFeature -Name "XPS-Viewer"

 

07-01-2013 15-54-44

Now it start removing “XPC-Viewer”

07-01-2013 15-54-57

one all done this will show the success windows. you can see in the command line output the value of Success is True.

07-01-2013 15-56-13

to cross check the un-installation lets run  Get-WindowsFeature -Name "XPS-Viewer" again.

and the you can see there is no [x] boxed in the front of the “XPS Viewer” and the install state is available.

07-01-2013 15-56-31

Thanks

Aman Dhally

 

clip_image001 clip_image002 clip_image003 clip_image005 clip_image007

Thursday, January 3, 2013

Installing Windows Features using Powershell V3

Hi,

While working on Powershell V3 i have realised that Scripting are going to be easy. Scripters just need to add bunch of cmdlets to the scripts and done. In Powershell V3 Microsoft had make CMDLET for almost everything or for every task.

The main task which SYSADMINS do this installing extra windows features in to the server or to the desktops. These features may be setup a server a DHCP,DNS,FAX or a simple feature like installing or enabling XPS viewer.

I am using a fresh installation of “Windows Server 2012 Standard Edition with GUI” and i do often view and read “XPS formatted  Documents”. BY Default the XPS file viewer is not installed on “Windows server 2012”. 

So i think why not install it using the Powershell V3 cmdlet. 

To get the list of all available/installed windows feature we can use the cmdlet

“Get-WindowsFeature”

The features those have [x] in the from of them means that they are installed.  When you query any single feature using  “Get-WindowsFeature” cmdlet then provide the NAME of the feature not the “Display Name”

03-01-2013 12-07-44

Let’s see if the “XPS Viewer” is installed or not.

Get-WindowsFeature -Name “XPS-Viewer”

You can see that XPS-Viewer is available but it is not installed.
03-01-2013 12-08-46

To install Windows features we have to use the cmdlet “Install-WindowsFeature

Let’ install XPS-Viewer, run the below command line.

Install-WindowsFeature -Name “XPS-Viewer”

You can see it start Installing.

03-01-2013 12-10-05

When installation is done it shows the below screen, that installation is “Successful” and Reboot is “Not required” .

03-01-2013 12-11-47
let’s query the “XPS-Viewer” again using Get-WindowsFeature

Get-WindowsFeature -Name “XPS-Viewer”

and now we can see a [x] in the front of Display Name and the Install State in “Installed”

03-01-2013 12-12-12

and we can see XPS Viewer on our Desktop too.

03-01-2013 12-13-25

Nice Smile isn’t.

Thanks

Aman Dhally

 

clip_image001 clip_image002 clip_image003 clip_image005 clip_image007

Wednesday, January 2, 2013

Setting Display Resolution using Powershell V3

Hi,

First of all I want to congratulate all new MVPs and want to thanks them their contribution to the community . I also want to congratulate “Sarabpreet Singh Anand” who became a “SQL” MVP this year for first time, brother we do proud on you.

Today “New Delhi” is feeling like a big refrigerator the temperature is almost 8 Degree Celcius and a heavy fog is every where.

02-01-2013 13-27-24

anyway…..

I am in love with Powershell V3, I think in this new version we have CMDLET for each and every task. Today i am going to show you a very simple task , the task in setting Display Resolution on Desktop using Powershell V3 Cmdlets.

Open PowerShell Console { You know hot to do this ;o) }

02-01-2013 13-06-19

To know you current display resolution use this cmdlet “Get-DisplayResolution”.

02-01-2013 13-07-04

So my current display resolution is “1920x1080” . Now lets change the resolution using the another cmdlet “Set-DisplayResolution

type and run “Set-DisplayResolution

it ask you to define the width of resolution in pixels : i typed 800

02-01-2013 13-07-50

after define the width in Pixels we have to provide the height pixel size of 600

02-01-2013 13-08-07

02-01-2013 13-10-01

Hit enter .

Now a new windows opens and asking for the confirmation that if we want to apply the display setting or not, if you enter “Y” new display resolution will be applied, if you enter “N” then you are back to the original display resolution nothing will be changes and if you type or enter nothing you will be back to original display settings.

In my case i type and enter “Y”

02-01-2013 13-08-32

and my display resolution is changed.

02-01-2013 13-09-36

Smile cool…..

but wait… we can make the above in to  one-liner so that we can  use this on our scripts so that it won’t ask for any confirmation window.

Set-DisplayResolution -Width 800 -Height 600 -Force

02-01-2013 13-38-52

 

Thanks

Aman Dhally

 

clip_image001 clip_image002 clip_image003 clip_image005 clip_image007

Tuesday, January 1, 2013

Managing Control Panel Items using Powershell v3.

Hi,

First of all “Happy New Year” everyone. New year is started and this is a good time to start learning  new things. I think the best things to learn for me is a “Powershell Version 3”.

Yesterday i installed a “Windows Server 2012 Standard Edition with GUI” in a virtual machine. As i am planning to cover new cmdlets on “Powershell Version"3” and then we can end up by writing scripts.

01-01-2013 11-21-04 “I like  it”

The interface of “Windows Server 2012 Standard Edition”  is pretty neat and clean. I like GUI interface of the server 2012 to be it feel very sober and attractive”

My current “Windows 2012 Server” machine is a standalone and not added to Active Directory yet.

To check the version of Powershell on “Windows 2012 server” Click on Powershell icon to open powershell console and type the cmdlet “$PSVersionTable

$PSVersionTable

You can see in below image that the Powershell version 3.0 is installed.


01-01-2013 11-24-01


In few of my old scripts when i want to open any control panel item i used to call the .CPL extensions. for example if i want to open “Network Connection” then i used to call “NCPA.cpl” in my script.


But in Powershell V3 they actually created a 2 new cmdlets to open control panel items and believe me they are going to be very handy.


The first cmdlet is “Get-ControlPanelItem

Get-ControlPanelItem


when you run “Get-ControlPanelItem” in Powershell console this gives  list of Names of  all items those are in control panel.


01-01-2013 11-25-50


Now we know how many and which items we have in control panel. To open those items we need second cmdlet which “Show-ControlPanelItem

Show-ControlPanelItem

lets open few control panel items.

Show-ControlPanelItem -Name "Folder Options"

01-01-2013 11-29-31


and lets open Display Properties.

Show-ControlPanelItem -Name "Display"

01-01-2013 11-27-53


Cool isn't?


Thanks


Aman Dhally


join aman on facebook Join aman on Linkedin follow aman on Twitter blogger-icon