Find a user (or any object) exists in Active Directory


With all Microsoft Active Directory Module for PowerShell, it doesn’t have an cmdlet to simply search a user or group in AD to find it exists or not. Get-ADUser or Get-ADGroup spits an ugly error message if it doesn’t find the object.

I wrote an PowerShell function to do exactly what I wanted. Simple search the given user or group, return True if it exists or return False. If you need it, feel free to use this function.

Download the script here: http://1drv.ms/1iVQaf6

#
# Function: IsUserExists
# Parameter: SamAccountName of the user
# Purpose: Find the user existing in AD or not. Returns True
# if the user exists, or returns False
#
# Written by Anand Venkatachalapathy
#
Function IsUserExists()
{
Param ( $username = “Administrator”)
$strFilter = “(&(objectCategory=User)(SAMAccountName=$username))”

    $objDomain = New-Object System.DirectoryServices.DirectoryEntry

    $objSearcher = New-Object System.DirectoryServices.DirectorySearcher
$objSearcher.SearchRoot = $objDomain
$objSearcher.PageSize = 1000
$objSearcher.Filter = $strFilter
$objSearcher.SearchScope = “Subtree”

    $colProplist = “name”
foreach ($i in $colPropList){$objSearcher.PropertiesToLoad.Add($i)}

    $colResults = $objSearcher.FindAll()

    If ($colResults.Count) { Return $true }
Else { Return $false }

}

PowerShell: Check the user is member of a Group (including Built-in Groups)


The issue with Get-ADUser JohnDoe –Properties MemberOf cmdlet is it doesn’t list Domain Built-in groups like Domain Users. I am not sure why Microsoft wants to hide built-in groups from listing user group memberships. So I have written a VB Script style function.

To use this function, copy & paste this function to your PowerShell script and call the function with username and groupname to check. E.g., IsMember –User JohnDoe –Group “Domain Users”

Download the Script: http://1drv.ms/Ts9Yv3

#
# Function: IsMember
# Parameters: AD User Name (SAMAccountName) and Group Name
# Description: Check if the provided User is member of given Group name.
# Returns True if the user if member of the group or returns False.
#
# Speciality: This function lists groups and check the group membership
# including Built-in groups like Domain Users.
# The Get-ADGroupMember from PowerShell AD Module doesn’t list
# built-in groups like “Domain users”, but this
# function does.
#
# Usage e.g.,: If (IsMember -User JohnDoe -Group “Sales-NA”)…
#
# Written By: Anand, the Awesome, Venkatachalapathy
#
Function IsMember()
{
Param (
[string]$User=$(Throw “Error: Please enter a username!”),
[string]$Group=”Domain Users”
)

Import-Module ActiveDirectory

#Get the Domain Name or you may assign it manually to
#$DomainName variable below
$DomainName = (Get-ADDomain).NetBIOSName

# Bind to specified user in domain.
$UserObj = [ADSI]”WinNT://$DomainName/$User,user”

    # Invoke the Groups method.
$GroupsObj = $UserObj.psbase.Invoke(“Groups”)

    ForEach ($GroupObj In $GroupsObj)
{

# Retrieve name of group.
$GroupName = $GroupObj.GetType().InvokeMember(“Name”, ‘GetProperty’, $Null, $GroupObj, $Null)

#Check the Group, if given group and current group name is same, return True
If ($GroupName.Equals($Group)) { Return $true }
}

#Group Not found, send False
Return $false
}

Excel: Paste multi-line text into a cell


If you copy and paste multi-line text into a Excel cell, Excel pastes into multi-row or multi-column data. This blog tip is to show how to paste a text into a cell and preserve the tabs and paragraphs into the same cell.

Solution:

1. Copy your multi-line text (Control-C)

2. On Excel, Select the cell and click on Formula bar and paste text. OR Select the cell, press F2 and paste the text. 

image

Hope it helped you. Enjoy Smile

Windows 8.1: Where the heck is Start-up folder?


Microsoft ditched the start-menu in Windows 8. I get that. BUT we used to get to the start-up folder using start-menu, so we can place few shortcuts to start automatically when we log in.  How the hell am I going to find it in the GUI? Sad smile No where.

I searching around and found where the heck is start-up folder. Its under freaking “C:ProgramData” folder. Copy the following path and paste it in run box (Windows +R)

C:ProgramDataMicrosoftWindowsStart MenuProgramsStartup

Place your software/program shortcuts here. Smile

How to Create a bootable Windows 2012 R2 USB Disk? (applies to Windows 8.1 also)


Pre-requisites: 7-Zip software (Download it from here: http://7-zip.org/), Windows 2012 (R2) ISO (or Windows 8.1 ISO), 8GB or more USB disk

  • Open Command Prompt in elevated mode (Run as Administrator)
  • Type diskpart and press Enter
  • Type list disk and press Enter. Note the list of existing disks.
  • Insert the USB Disk
  • Type list disk and press enter again. Note the new disk showed up which is our USB disk. I assume the new disk is 2 for example purpose.
  • Type select disk X where X is your USB disk. E.g., select disk 2. Press Enter.
  • Type clean and press enter.
  • Type create partition primary and press enter to create primary partition 1.
  • Type select partition 1 and press enter.
  • Type active and press enter to make the partition 1 active
  • Type format fs=ntfs and press enter. This will format the partition 1 as NTFS volume.
  • Type assign and press enter to assign the USB disk to a drive letter.

 

  • Now right click on Windows Server 2012 R2 or Windows 8.1 ISO file, select 7-Zip –> Extract Files…
  • Select your USB disk to extract the ISO contents to the USB disk

That’s all. Boot the server or computer using the bootable USB disk.

Did it help you? Leave me a Thanks.

Outlook 2013 (&2010): Pictures in Signature–How to?


In Outlook 2013 (& 2010) if you paste or insert an picture (e.g., Logo) in Signature Editor, it is not resizable. You are stuck and not able to do a correct sized picture in Logo. But No worries. There is an very simple trick that you can make the signature however you want.

  • Click New E-mail in Outlook 2013 (or 2010)
  • Type and insert the picture and make the signature that way you want.

image

  • Now Copy the whole thing in the compose window.
  • Click Insert –> Signature –> Signatures..
  • Click New and type a name, click OK.
  • Paste the copied signature

That’s it. Enjoy. Smile

RDS 2012 R2–Single sign on using Windows Authentication for RDWeb page


WebSSO is great and it works beautifully if configured correctly. If you go https://rdwebserver.company.com/RDWeb, you will be presented with form based authentication page.

What if we present the published apps/icons without presenting form-based authentication page, meaning use Kerberos or NTLM authentication with logged of user. This makes sense for internal corporate users, they are already logged in with their domain credentials and who do they have to logon again.

This blog is to achieve Windows Authentication for RDWeb logon. It’s really easy to do in Windows Server 2012 R2.

  1. Logon to Remote Desktop Web Access server.
  2. Open Explorer and go to C:\Windows\Web\RDWeb\Pages
  3. Make a backup copy of web.config file.
  4. Open Notepad as Administrator
  5. Open C:\Windows\Web\RDWeb\Pages\web.config
  6. Uncomment Windows Authentication section and comment Formbased authentication. The end result would like this:

    <!–
To turn on Windows Authentication:
– uncomment <authentication mode=”Windows”/> section
– and comment out:
1) <authentication mode=”Forms”> section.
2) <modules> and <security> sections in <system.webServer> section at the end of the file.
3) Optional: Windows Authentication will work in https.  However, to turn off https, disable ‘Require SSL’ for both RDWeb and RDWeb/Pages VDIR.
Launch IIS Manager UI, click on RDWeb VDIR, double click on SSL Settings in the middle pane, uncheck ‘Require SSL’ and
click Apply in the top right in the right pane.  Repeat the steps for RDWeb/Pages VDIR.
–>

    <authentication mode=”Windows”/>

<!–
<authentication mode=”Forms”>
<forms loginUrl=”default.aspx” name=”TSWAAuthHttpOnlyCookie” protection=”All” requireSSL=”true” />
</authentication>
–>
<webParts>
<personalization defaultProvider=”TSPortalProvider”>
<providers>
<add name=”TSPortalProvider” type=”Microsoft.TerminalServices.Publishing.Portal.TSPortalProvider”/>
</providers>
<authorization>
<allow users=”*” verbs=”enterSharedScope”>
</allow>
</authorization>
</personalization>
</webParts>
</system.web>

Enable Windows Authentication in IIS settings

1. Open IIS Console on the RD Web Access Server
2. Expand to RDWeb folder.
3. Double click on Authentication.
4. Disable Basic Authentication and Enable Windows Authentication

That’s all, BUT there is one more thing. Since we don’t use form-based authentication, how would you specify it’s Public or Private. On RDWeb page there is a check box to make the RDWeb sessions private. It shows up in the bottom as below.

 

I made this Private checked by default since all my users are internal (& I have different Remote desktop web access server for external users with form-based authentication). To make that happen follow the steps below.

  1. Logon to Remote Desktop Web Access server.
  2. Open Explorer and go to C:\Windows\Web\RDWeb\Pages\en-US
  3. Make a backup copy of Default.aspx file.
  4. Open Notepad as Administrator
  5. Open C:\Windows\Web\RDWeb\Pages\en-US\Default.aspx
  6. Modify the variable bPrivateMode to true (from false). The modified variable line looks like this:

public bool bShowPublicCheckBox = false, bPrivateMode = true, bRTL = false;

Now it looks like this, since Private mode is checked by default.

image

Hope this helps you. Enjoy!!

Windows 8: All installed Applications in one folder like Mac OS X


If you liked how OS X have an Applications folder, you can do that in Windows 8.x also. It’s very easy.

1. Open Explorer

2. Go to a location where you want to create Applications Folder (e.g., Documents)

3. Create a new folder and rename the folder to Applications.{4234d49b-0245-4df3-b780-3893943456e1}

4. That’s all. Open the Applications folder, you will see all installed applications on your computer including Metro apps.

image

Windows 8.1: Easy Shutdown method for touch screen computers


The straight forward method of shutdown the Windows 8.x tablets is bring the charms bar (slide from right to left on the right side of the screen), click Settings, Power and then Shutdown. (Well, you can press and hold the power button too).

To make things little easier you can place a tile/icon on the start menu for the file “C:WindowsSystem32SlideToShutDown.exe”. This executable will bring Windows Phone style shutdown screen (slide down to shutdown).

Step-by-step instructions (if you like).

1. Open Windows Explorer and go to C:WindowsSystem32 and find the file SlideToShutdown.exe.

2. Right click on the file and choose Pin to Start. (Tip: You could use Obly Tile to create a new tile with cool looking icon).

image

Slide to Shutdown screen looks like this:

image

Windows 8.1: Photo Slide Show on your Lock Screen


When you lock your Windows 8.1 computer/tablet, it shows the your default logon screen picture. You can enable photo slide show on your lock screen. To do this, make sure you have some photos or picture readily available on your Pictures folders (or anywhere on the computer hard disk).

  • Open PC Settings (Move your mouse cursor to bottom-right corner, click settings (gear icon) on the charms bar and click Change PC Settings)
  • Click on PC and Devices and them select Lock Screen

  • Turn ON the slider for Play a slide show on the lock screen
  • If you photos are in Pictures folder, you are done. If not, Add folder in the list.
  • Click Back button and close PC Settings (Alt-F4 would be quick way).

That’s all. Enjoy your slide show on the lock screen. Smile