Archive for the 'howto' Category

extract & untar

This is a one step command to extract and untar a tar.gz file.

tar zxvf filename.tar.gz

z = Gunzip(uncompress) it before extracting, used on file ending in .tar.gz or .tgz
x = Extract the contents of the TAR file
v = Verbose – display contents as it is tarring or extracting
f = Filename to follow

Note: If the file does not have “.gz” extension that means its already uncompressed and one has to just extract it using “tar xvf” command.

This is a two step command to extract and untar the file.

gunzip filename.tar.gz

tar xvf filename.tar

Remote management of Exchange 2010 using PowerShell

You can run powershell commands on your Exchange 2010 server from machines whether or not they have the Exchange Management Tools installed using implicit remoting.

Even when you run the Exchange Management Shell on your exchange server, you’re essentially creating a powershell remoting session. The following steps take place in the background when you click the EMS icon:

  • Load the Microsoft.Exchange.Management.PowerShell.E2010 snap-in gets loaded
  • The RemoteExchange.ps1 script is dot sourced
  • The Connect-ExchangeServer function is executed
  • You can set up implicit remoting from any maching using powershell v2. This imports the commands from your exchange server to your local powershell session so you don’t need any Exchange tools installed.

    First we create a session using the New-PSSession cmdlet:

    $s = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://<CAS FQDN>/PowerShell/ -Authentication Kerberos

    Then, import the session using the Import-PSSession cmdlet:

    Import-PSSession $s

    The Exchange Management Shell commands are now imported into the local PowerShell session.

    You could use the same method to setup a scheduled task from your machine to run a commands on your exchange server.

    [source: ]

    Active Directory integration in CentOS using SAMBA

    This is perhaps the best tutorial on how to set up Active Directory integration in CentOS.

    http://www.linuxmail.info/active-directory-integration-samba-centos-5/

    Update:
    A related link on setting up Kerberos
    http://www.howtoforge.com/samba_ads_security_mode

    How to tell what distro you are running?

    So you inherit a box running linux and you have no idea which flavor of linux it is. How do you find out?

    If all you need the kernel version you can try
    uname -a

    This outputs something like this

    Linux localhost.localdomain 2.4.20-31.9 #1 Tue Apr 13 18:04:23 EDT 2004 i686 i686 i386 GNU/Linux

    If you need the actual distro name you can try
    cat /etc/*release

    In Ubuntu it shows up as

    DISTRIB_ID=Ubuntu
    DISTRIB_RELEASE=9.04
    DISTRIB_CODENAME=jaunty
    DISTRIB_DESCRIPTION=”Ubuntu 9.04″

    Or even
    cat /etc/issue

    which spits out the following on Ubuntu

    Ubuntu 9.04 \n \l

    You can combine all three to get the following
    uname -a && cat /etc/*release && cat /etc/issue

    Update:
    Another one to add to the list
    cat /proc/version

    Batch editing Dial-up or VPN access settings in Active Directory

    Active Directory doesn’t let you edit the Dial-up of VPN access policies for multiple users at once through the GUI. You have to edit this setting one at a time for each user. This can be painstaking if you a lot of users. Luckily there is a VB script available like for almost everything else in AD.

    Dim aConnection, aCommand, aResult, strLDAPPath, user, objUser
    Const ADS_PROPERTY_CLEAR = 1
    strLDAPPath = InputBox("Please enter the LDAP path of the OU:")
    WScript.Echo strLDAPPath
    Set aConnection = CreateObject("ADODB.Connection")
    Set aCommand = CreateObject("ADODB.Command")
    aConnection.Provider = "ADsDSOObject"
    aConnection.Open
    aCommand.ActiveConnection = aConnection
    aCommand.CommandText=";(&(objectCategory=Person)(objectClass=User));distinguishedName;subTree"
    Set aResult = aCommand.Execute()
    Do While Not aResult.EOF
    strDN = aResult.Fields("distinguishedName")
    WScript.Echo strDN
    Set objUser = GetObject("LDAP://" & strDN)
    ' Comment the following line to manage connection through Remote Access Policy
    objUser.Put "msNPAllowDialin", FALSE
    ' Uncomment the following line to manage connection through Remote Access Policy
    ' objUser.PutEx ADS_PROPERTY_CLEAR, "msNPAllowDialin", 0
    objUser.SetInfo
    aResult.MoveNext
    Loop


    This script will update the access settings for a group of users in a particular OU. Once you run the script, a dialog box will ask you for this OU. Once this is set all users in that OU will be updated.

    The AD property this script modifies is ‘msNPAllowDialin’. This property is accepts boolean values. So the three options are

  • TRUE (to allow access)
  • FALSE (to deny access)
  • To manage access via the Remote Access Policy, comment out the

    objUser.Put "msNPAllowDialin", FALSE

    and uncomment the

    ' objUser.PutEx ADS_PROPERTY_CLEAR, "msNPAllowDialin", 0

    line.

    -