Monday, May 28, 2012

Citrix and Powershell Remoting

 

A person who never made a mistake never tried anything new”
                                                                                                                                                                                -Albert Einstien

In this one, I will try to show the good old PowerShell Remoting and Citrix Remoting. Please note that you can only use Citrix Remoting only if you have XenApp 6.5 Servers running in your farm. If you have XenApp 6 or below versions supported by Citrix then you  have to rely on PowerShell remoting.

If you want to know about PowerShell Remoting then I highly suggest the following free-ebooks

MVP Ravikanth’s “Layman’s Guide to PowerShell Remoting

PowerShell Guru MVP Don Jones & MVP Tobias Weltner’s “Secrets of PowerShell Remoting

 

I have a Lab Setup with:

·         domain name POSH.com …….(cool isn’t it :P )

·         Administrator Workstation named “POWERSHELL” (PowerShell SDK for XenApp 6.5 installed )

·         Remote XenApp 6.5 Server “CTXXENAPP01” with PSRemoting enabled.

·         User POSH\201210 has  full Farm Admin privileges.

 

Citrix with PowerShell Remoting

Open the PowerShell Console. And create a  New PowerShell Session in the remote Citrix XenApp Server using the full Farm Administrator Credentials

clip_image002

After Opening the PowerShell Session in the Remote Citrix Server. Enter the Session using the –Id parameter.  Once you enter the Remote PSSession the console is prepended with the Remote Citrix XA Server Name .

clip_image004

Now , Get all the Snap-ins available in the Citrix XA Server. The following snapshot shows the Snap-ins registered with the Citrix PowerShell SDK , the ones we are interested in are Citrix.Common.Commands, Citrix.Common.GroupPolicy  and Citrix.XenApp.Commands.

clip_image006

 Now load the specific Snap-ins one-by-one or just add them using a wild-card (your choice). Notice that I had Citrix WorkFlow Studio installed too in my Remote Citrix XA Server, so those snap-in also get loaded if I use  a wild-card.

clip_image008

After the Citrix XA Snap-ins are loaded, to have a look at  all the new cmdlets available to manage XA Farm. You can use noun “XA*” with Get-Command because Citrix Cmdlets have XA prepended in the Noun part of Verb-Noun naming convention to easily identify them. There is also a cmdlet that comes with these Snap-ins Get-CtxCommand  which does the same.

clip_image010

Now Citrix XenApp Server is on-demand application delivery solution. So it deals mostly with administration of published Applications. So let’s search something like XAApplication with Get-Command. This will yield all the cmdlets that are available to administer Applications. 

clip_image012

Now time to explore.  The best thing about PowerShell is it’s documentation right. Don’t Worry Citrix also provides you a great Offline help documentation. Now you can look at the examples and get what the cmdlet does for you.

clip_image014

Viewing the Examples. Pretty self explanatory examples …I guess J

clip_image016

Now let’s execute a simple cmdlet Get-XAApplication. Now this cmdlet retrieves all the published Application informationclip_image018

 If you wanted a detailed information then you could use Get-XAApplicationReport.

clip_image020

The best thing about using PowerShell is whatever you have learned ….can be incorporated here too. For example in following example Invoke-Command is used to retrieve the published application information from the remote Citrix XA server and then that information is being piped into Out-file cmdlet to store it into a text file.

This is a very na├»ve example here but look at the Power it holds for Citrix XA Farm Admins. Suppose you wanted to get the list of  all the published applications in different farm ,  generate a report for Server memory  Optimization Information , retrieve Citrix Load Evaluators and much more.

clip_image022

 

A Little bit on Citrix Remoting

XenApp 6.5  PowerShell  SDK  for Citrix comes with a brand new feature Remoting , which was earlier not present in the XenApp 6 PowerShell SDK. All the cmdlets shipped with the SDK now support a –computername  parameter  which indicates  to the cmdlet to execute remotely. Now this has  a huge impact , such that now I can install the PowerShell SDK on any machine ( Windows Machine) running PowerShell v2.0 and manage my farm from there. Note that no additional configurations are needed in the client or server.

XenApp 6.5 implements this new feature by introducing a new Windows Communication Foundation (WCF) service named Citrix XenApp Commands Remoting. This service implements Remoting in the XenApp 6.5.

Following is a status of the Citrix Remoting Service running on the XenApp 6.5 Server.

clip_image024

To use Citrix Remoting , you don’t need to install the PowerShell SDK on the Remote Citrix XA Server instead you install it on the local  Administrator Workstation and load the snap-ins and use the commands like native PowerShell cmdlets specifying the remote Citrix XA Server to contact using –computername parameter. It’ll look something like this

clip_image026

I have tested this one and this works fine as well, But as of now didn’t had a proper screenshot. I will try to cover this one later with proper steps.

 

Thanks

Deepak Singh Dhami
Deepak Singh 

Friday, May 25, 2012

Sherlock Holmes: Secret of encrypted PowerShell Script files.. Password Protect .PS1 files using VIM.

 

sh_profile7

Hi,

This article is quite off from my regular PowerShell topic, but it's fun doing it .  So the situation is like that, One of my friend wrote a Powershell script but someone he wants to encrypt or password protected so that on one else {his fellow colleagues who just believes in COPYING & PASTING and make no efforts to learning technologies} use it, copy it .

When is asked me this question, i was not sure what to do,,as i always believe is sharing...then VIM come to my mind and in my one previous article i also mentioned about vim in this blog. You can find the article here:

 http://newdelhipowershellusergroup.blogspot.in/2011/11/hi-i-hope-some-of-you-know-about-what.html

Let's start.

so we have a enc.ps1 file in D drive and that file contains a two line script.

25-05-2012 12-24-39

run the script , So all is good... we have a script file and that file is running successfully.

25-05-2012 12-26-16

, I hope that you already have VIM on you laptop if not check my previous article which i mentioned in the beginning of this article.

now just open the enc.ps1 file in vim so that we can check that if file is opening in the vim or not.

25-05-2012 12-30-20

ok, file is opening, now press "ESCAPE" key and type q! in vim. {q means quit}

25-05-2012 12-31-01

now open the file again with -x parameter on vim. {small x not X (as VIM is based on Linux and Linux is case sensitive)}

25-05-2012 12-32-58

Now it ask you to enter a encryption password, provide it .

25-05-2012 12-33-28

Ok type the same password again.

25-05-2012 12-34-21

It open our .PS1 file,, now type,press "Escape" key again., in colon type wq! and press enter {w=write, q=quit}

25-05-2012 12-35-09

okies we are back to our Powershell console.

25-05-2012 12-36-51

Now lets open our enc.Ps1 Powershell script file in notepad.

Ooops,, i don't know this "Alien's" scripting language,, i think we need "Sherlock Holmes" to decode it..

25-05-2012 12-38-35

Mission accomplished :-)

Now whenever you open the same file in VIM it ask you for password first.

25-05-2012 12-41-02

asking for password to open the file.

25-05-2012 12-41-18

and if someone runs it. :)

Damn!!!!! :)

25-05-2012 12-42-30

oh !!!! and how to change or remove password :)

Open the file in VIM , Enter you password to open it . press "ESCAPE" key and type :X {capital } and hit enter.

25-05-2012 12-45-35

if you want to change password provide it , if you want to remove the password, jut keep it blank and press Enter.

25-05-2012 12-45-57

Press Enter again

25-05-2012 12-47-28

now press "Escape" , type wq! {write, quite, forcefully}

25-05-2012 12-47-59

Now we are back in Powershell console. now open the same file in "notepad"

25-05-2012 12-50-04

Wow !! we back from where we start.

I hope that you enjoyed this post.

Thanks

Aman Dhally

Buy-More-Twitter-Followers

00485s99

Thursday, May 24, 2012

Fix Client DNS Issues and IP Address using Powershell.


Hi,

I think everyone know that IT administrators like me are lazy... We don't like to do repetitive work and we also don't believe in trying same word and commands again and again. I think most of you will be agree with me :)

Today i did some changes in our local DNS,DHCP server. So for some reason we need to flush DNS Caches from the system also need to do Release and Renew IP-Address. 

To easy my work load so that i can spent more time on FACEBOOK .. i wrote a simple small script which is just running our native command Ipconfig. The same command help us to flush DNS as well as Register DNs.

You can download the script from below link, Nothing fancy jus a simple script.

Download from here :http://gallery.technet.microsoft.com/scriptcenter/Fix-Client-DNS-Issues-and-a8b88726

24-05-2012 15-15-07

Download from here :http://gallery.technet.microsoft.com/scriptcenter/Fix-Client-DNS-Issues-and-a8b88726

Thanks
Aman Dhally
old_mickey_mouse

Tuesday, May 22, 2012

Import only specific Cmdlets from Module in Powershell.

 

Hi,

Sometime in Scripts we imported whole module but we need only we cmdlets of that module. For example i am working on a script which run on "Active Directory",  but in "Active Directory" module i am using only two cmdlets Get-ADUser,Get-ADGroup , so it seems wise if we able to import only these cmdltes rather then whole bunch of other Cmdlets which we are not going to use in the script.

we can do this using -Cmdlet parameter in Import-Module Cmdlet,

Import-Module ActiveDirectory -Cmdlet Get-ADUser,Get-ADGroup

Now we are importing only two cmdlets  Get-ADUser,Get-ADGroup from "Active Directory" Module.

22-05-2012 11-13-29

Ok, Module imported successfully now check which cmdlets "Active Directory" have { i already show you how to do this here }

Get-Command -Module ActiveDirectory

22-05-2012 11-13-40

Yo!!!, Module have has only two Cmdlets which we told him to import.

Cool!! Isn't.

Thanks for reading.

Aman Dhally

joker_nurse

Monday, May 21, 2012

List All Cmdlets of a Specific Module in Powershell.

 

Hi,

sometime you need to know only some or all specific cmdlets for  a module. For example you just imported an "Active Directory" Module and want to know which all cmdlets imported by it.

Let's import an module first.

Import-Module ActiveDirectory

30-04-2012 23-21-03 

ok, Module is imported,,

now run the below command to list all cmdlets imported my "Active Directory" Module.

Get-Command -Module ActiveDirectory

So here is our all Active Directory Related Cmdlets.

21-05-2012 17-23-01 

Thanks

Aman Dhally

simba_lion

TechED 2012 Bangalore, INDIA ..Memories..

 

Hi,

I think that i never shared my Tech_Ed 2012 pictures with you ..

Here are the Few Clicks..

Thanks

Aman Dhally

Thanks Microsoft.

 

HI,

I am just thanking Microsoft and UGSS Group for sending the 4 hard copies of " Microsoft  Office 365, Connect and Collaborate virtually anywhere anytime" book.

This book is shipped directly from "Microsoft Headquarter" in Redmond U.S.A.

Thanks Microsoft one again..

photo-1 - Copy photo-3 photo  

Thanks

Aman Dhally

Tuesday, May 15, 2012

Powershell and Active Directory: Remove domain user from domain Group using Powershell.

 

Hi,

Today my IT Manager told me to remove a domain user from a specific group. Normally i used "DSA.MSC" or we can say that "Active Directory users and Computers", then i find users, go to his user account properties and click on "Member Of" tab and delete the group which the user is not required.

We can do two things.. Either we can use Get-ADGroupMember cmdlet to find the group  all group member of a particular group,or, we can use Get-ADUser cmdlet to find a group membership of a particular user.

Lets 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,,

Let's use Get-ADUser cmdlet to find group membership of a domain user { http://newdelhipowershellusergroup.blogspot.in/2012/05/powershell-and-active-directory-find_11.html }

$((Get-ADUser Aman.Demo -Properties *).MemberOf -split (",")  | Select-String -SimpleMatch "CN=") -replace "CN=",""

Ok now we know that user "Aman.Demo" is a member of a Fax-Dubai and two others group. Our target is to remove "Aman.Demo" from "Fax-Dubai" Group.

15-05-2012 14-14-18

Let's cross-check if "Fax-Dubai" have a "Aman.Demo" as a member.

Get-ADGroupMember -Identity "Fax-Dubai" | Select-Object Name

Yes it has... Now lets remove "Aman.Demo" from the Group.

15-05-2012 14-28-24

we are Remove-ADGroupMember cmdlet to remove user from the desired Group.

Remove-ADGroupMember -Identity "Fax-Dubai" -Members "Aman.Demo"

before removing the user from the group it ask you for confirmation , type "Y". That's all.

15-05-2012 14-33-44

if you want to suppress Confirmation, you can use -Confirm:$false parameter , after it it wont ask for confirmation.

15-05-2012 14-36-44

ok. now we already removed the user from the group , let's check it now.

User "Aman.Demo" is a member of 2 user groups now previously it was 3, and you can see there is no "Fax-Dubai" exists in Members of now.

15-05-2012 14-39-14

All Sorted :)

Thanks for reading the blog.

Aman Dhally

Aman Dhally