Wednesday, 24 August 2016

Search for user existence in a domain - Powershell

Validate User existence in a domain using text file input: 


Last week, I had received request to migrate some list of users using ADMT tool, but I know some users in the list were already migrated because few names which I looked in the file are familiar to me...

List contains around 50 users and I don't have time to validate each and every user in a domain for their account existence. Hence I remember the try catch method which I used earlier for checking the AD user account existence.

Note: The input file contains the SAMACCOUNTNAME of the objects. Just input those samaccoutname into the notepad text file and saved with "userscheck.txt" and save the input file to c:\temp folder

Solution:

Please find below the script content.. This time I have added the cmdlets to generate CSV file based on the validation.

# Script Contents --- Script shared with no warranties.. it was developed based on our test environment. Please read carefully, modify and use it as required .

#********************************************************************************

# Setting Default location to c:\temp Directory and Getting contents into variable

Set-Location 'C:\temp'
$data=Get-content '.\userscheck.txt'

# Preparing the CSV file output formats and path

$logpath="c:\temp"
$logdate = (Get-Date -Format ddMMyyyy)
$logfilename= $logdate+ ' ' + ‘User-checking’+".csv"
$out= $logpath + '\' + $logfilename

Import-Module Activedirectory

Add-content $out -value “Userid,Exist”

foreach ($user in $data)

{

Try {
        Get-aduser $user -ErrorAction stop |out-null

        Add-Content $out -Value "$User,YES"
    }
catch
    {
        Add-Content $out -Value "$user,NO"
    }
   
}

#*******************************************************************************






Wednesday, 17 August 2016

Porxy PAC file GPO- Registry Item-GPP Method


Deploying Proxy PAC file configuration through GPO-GPP – Registry update method: 


I had received request from our team to setup the proxy PAC file configuration for VDI clients, hence I started preparing the GPO with User configuration settings.

They had mentioned that PAC file configuration which we set in the IE -Connections - Lan Settings should be editable by users, hence I decided not to use the GPP- Internet Settings to deploy the IE configuration based on the IE version target. 


Solution:

Created the New GPO for testing the new Registry Item for Proxy PAC configuration.

Updated the “AutoconfigURL” settings with PAC file Path on below registry path in User configuration.

HKCU\Software\Microsoft\windows\CurrentVersion\Internet Settings



I decided to check and it was working fine for my login and for the requestor as well...

After two or three days, few customers complaint that the proxy configuration is not displayed for them.



So, I logged into to those servers / clients where customer reported the issue … this is the first time I logged on to those servers. Surprisingly, GPO which I had setup does not apply in IE proxy configuration script option but GPRESULT report shows that registry item is processed.


I started to blame the IE Enhanced Security Settings but I checked it was in disabled Mode for both Administrators and Users.


In the problematic system, I manually tick the “Use Automatic Configuration Script” and Un-ticked it. Forced the Gpupdate using force switch. 


Magic, this time it was applied successfully. I found in Internet that we others also had similar problem, they had solution by Setting the following registry Key.  





















So, I have included this registry item also in the same GPO in Order 1.















Seems, to be working fine till now. Hope, this will be helpful for you as well...