Skip to main content

Posts

Showing posts from 2012

Transcripts : Leverage them

This post is a result of the query asked on the Facebook page of Bangalore PowerShell User Group . When someone asks a question regarding a Script, it becomes very difficult to follow through it especially if it  is related to some very different domain like SQL, SharePoint (especially for me). I personally feel one could attempt to even try answering the question if he knows what happens behind the scenes like the Verbose Output associated with the cmdlets one is executing and the type of Objects that are being emitted etc. Someone could ask the beginners to pipe the Objects into the Get-Member cmdlet to see the intricacies of the Object, or the Process one follows. Here we can leverage transcripts. Already transcripts are used by PowerShell Gurus in the presentations or trainings , so that later you can see them and find out what went in which order. In short Transcripts capture whatever appears in the PowerShell Console host. Note! Windows PowerShell ISE doesn't support t

ServerCore + Create Test Users using Facebook

So Recently my VHD got corrupted and had to make the VHD Boot again work. Thankfully I had all the PowerShell one-liners I used to get my Lab up in less time. First of all I will add 100 test users by following this awesome Hey Scripting Guys Blog Post . To make things a bit clear I am on a workstation with RSAT for Active Directory installed and my DC is a servercore machine. Just to give a hint when I need to run a cmdlet to get any information from the AD, I need to specify the name of the DC with -Server  parameter from where I want to get the information but a new connection will be opened and closed for each cmdlet invocation. For Example : Get-ADForest -Server dexservercore.dexter.com Better way explained in Active Directory PowerShell Blog is to map a PSDrive for better performance. Since I have only one DC in my test environment , when I Import the ActiveDirectory Module it will automatically map a PSDrive on my remote workstation. Now I don't want to a

Deploying AD Domain using PowerShell + Completing LAB Setup

I would like to divide this post in two parts : 1. Deploying a domain dexter.com on my Server Core . 2. Adding my Physical Host running Server 2012 to the domain dexter.com. Step 1. Deploying domain dexter.com on my Server Core. First of all I need to add the Active Directory Domain Services role in my Server Core. To get the Active Directory Roles on my Server Core use the following cmdlet The highlighted entry shows that the AD-Domain-Services Role is already installed on my Server Core. But if it is not then you can issue the following to install it. Install-WindowsFeature -Name AD-Domain-Services -IncludeManagementTools Now the role is installed and till Server 2K8 R2 , one would have gone and run the dcpromo.exe (this one is deprecated now with Server 2012) but here I will try to use PowerShell ..this is the link I followed Windows Server 2012 has a new module named " ADDSDeployment" and if I check the cmdlets supplied:   You get the idea...Now

Assigning Static IP Address to the Server Core

Now for the first time you boot a Server Core..you get nothing but a Command Shell (cmd.exe). Now before we begin further let's assign a static IP address to the Server Core VM. REMINDER : My Lab has server named "DexterPOSH" Server 2012( on Physical Host) and then in Hyper-V a VM named "dexservercore" running Server Core 2012. Open "Hyper-V Manager" and Right-Click and "Connect" to the VM (start it if it is not started yet) There are actually three ways to do this..You may be familiar with all three maybe but I wanted to list all the ways to do this. 1. Using Netsh utility - this one is old school But this one is depreciated see the screenshot below..It's recommending PowerShell ( will cover it in 3rd step) anyways to set the IP address..first get your interface by using : Now I have the interface with me...Time to set the IP address (old school) Okey done. 2 . Using Sconfig utility - Server 2K8 R2

Server 2012 and Server Core...New Plan

I am taking this new initiative to learn Server 2012 along with Server Core..... Lab Setup: I have VHD booted Server 2012 with full blown GUI on my Physical Machine (Name - DexterPOSH). Then I have enabled the Hyper-V role on my this machine and installed a Server Core 2012 on a VM created in the Hyper-V (Name - DexServercore). Along doing this Lab Setup, I came to learn cool things and I want to share them: Step 1 : Download the trial Server 2012 iso. Step 2 : I have a Windows 7 box , so to test the Server 2012 I am going to VHD Boot the Server 2012 for 180 days (license period) then delete the VHD and the boot entry. Here is a great article on how to do this for Windows 8 but the steps are the same for Server 2012 too. Step3 : Once you have VHD Booted your machine to Server 2012. Open our favorite PowerShell console and run the following to install Hyper-V role on the host  Get-WindowsFeature -name *hyper* | Install-WindowsFeature Reboot your machine to complete Hype

Resuming Blogging...

I was busy learning PowerShell and attending PowerShell events in India. Now, I am a member of New Delhi PowerShell User Group and Bangalore PowerShell User Group. I blogged occasionally for New Delhi PowerShell UG on Citrix and PowerShell . Just to get a hint of my inactivity on this blog....... I think I am back for good now.....

2012 Scripting Games : Beginner Event #2

The second problem for the SG 2012 can be found here In this Event there was a little confusion as to what I had to do.....But going through comments on this problem and Scripting Wife's hint the picture became clear that I had to only find the Stoppable running services (complicated eh !). Scripting Guy's design point can be a bit confusing at times but the key to solve is to think how to encompass all the design points. The Script I wrote worked fine..what I did was queried the services running on the system ,then filtered one running with the status "Running", then finally filtered those with canstop property set to $true........but when read the comments on my script I learned a few things Things learned: 1.  How to write compound Where clause.Read this article here . After reading this learned how to handle Boolean values and write compound where clause. 2. Read previous Scripting Games problem and solutions :) param (         $commputername = $

2012 Scripting Games : Beginner Event #1

I had heard a lot about Scripting Games and decided this year to participate in them. I was excited to see myself Script among other Beginners. This year they had done some changes such as One cannot participate in both Advanced and Beginner Section. One has to submit the script in 7 days after the Event goes online. The first problem can be read here: Beginner Event 1 Summary : Beginner Event 1 of the 2012 Scripting Games uses Windows PowerShell to identify a working set of processes. This was a bit easy for me as I had already read few blogs and books on PowerShell. Below is my script and I got 4.5 star rating for it. Though the event asked for one-liner , I wrote it this way. The key to get 5 Star rating is to keep focus on the design points and take your time to submit the script , copy paste what you have tested at least thrice . The Scripting Wife hints at Scripting Guy blog will give you a bit of idea as how to approach the problem. Some of the things I learned fr

Powershell + Facebook

This post i stumbled @Twitter by M$ MVP Don Jones. And this is really awesome stuff......Managing Facebook from Powershell ( a command line ) although i have heard of using Facebook from command line in Linux (using fbcmd) . Here it is the page for the PS module http://facebookpsmodule.codeplex.com The Author of this Module has done a really great job and given so many functionality at an alpha stage...Hoping for more. Steps : 1. Install the Module by clicking on it. 2 . Then Open a Powershell ISE or Powershell in STA mode..as the STA mode is needed. 3.  Then Import-Module facebook inside the console ( see below pic) 4. Then issue the command "New-FBConnection" and it pops-up the Connection Box 5. I face some error trying directly to set status after this...so did this issue "Show-FBConnectionDialog" and in pop-up grant access. 6. Now to take a loot at what you can do just key-in "get-command -module facebook". Heck a lot of t

GUI Editors for Powershell

What !!!!......I thought Powershell was a CLI Environment. Well the problem with the huge user base of Windows is that all the users (even those calling themselves as Admins) are a slave of Graphical Interfaces. Pop up a Powershell to a Windows Admin (experienced ones) and he has no idea what to do..... So the big guys at M$ came up with the Powershell ISE to ease the learning curve for those users and there are many GUIs now available for PoSh (who saw that coming :P ). Powershell Integrated Scripting Environment Go to Start and type "powershell ise" click on the top result and you are presented with a following screen. Now this GUI has a Ouput, Command, and Script pane. Read the help for more info. PowerGUI  Another great GUI tool for Powershell is PowerGUI from Quest Software. This GUI beats the Powershell ISE any day. I personally use this as it is the best free and has a huge community support. Go to http://www.powergui.org to get yourself  one.

The offline key to learning Powershell

 get-help I have been reading a lot about Powershell and Powershell Community has helped me a lot in various problems that I faced. There are lots of books and blogs available. But what if i have just powershell installed and no Internet connectivity...........then the only thing that comes to rescue is the " get-help " cmdlet ( commands referred as cmdlets in PoSh ) Now, it is pretty basic and has helped a beginner like me a lot. So how do i know how to use get-help ? Well the answer is simple, key in this get-help get-help Now try this get-help about* This lists all the about examples shipped with Powershell. These examples are very informative. Now, if you read the get-help's help then you know what to do...when you want to know about a new cmdlet...but wait how you discover all cmdlets in Powershell Key in this to  know how to discover new cmdlets. get-help get-command Few useful links: www.powershellpro.com  --- has got great tu
Real Power Shell lies in Objects The very first thing about Powershell which takes geeks by awe is that every cmdlet (same as command) in PS returns Object based ouput rather than text-based. Though this is the major reason for the success of Powershell but i think that Microsoft has done a great job integrating all the best things available as of now , just to name a few piplining, interpolation from Unix and programmatic constructs of Perl, Python and many more. Powershell gives geek a way to finally be free of the GUI but the question is do we really want to be free of the Graphical UI ? Another thing that is worth appreciating is that finally Microsoft is able to give users (say admins) the well documented help....Ohh! that was a long wait. Key in "get-help get-help -detailed" for how to use get-help. The commands referred to as cmdlets in Powershell are of a standard naming convention "verb-noun" now this is simple but is pretty awesome feature.....s
This is the #1 post for "Powershell for Freedom" blog. There's a reason for this name to blog. Hoping PS sets me free.