Michael Wu

The Life of a Cloud Engineer

  • Home
  • Resume
  • Blog
  • Contact

Posted on 08.12.16

Set Unix Attributes LoginShell from Active Directory with PowerShell

This post will show you how to update the Unix Properties (LoginSehll in this example) in AD object using PowerShell.

If you don`t see the UNIX Attributes tab in the AD Object Properties, you can install Identity Management for UNIX Components.

enable Unix ID 2

As you can see in the screenshot above, I would like to change the Login Shell to /bin/bash.

Here is the script.


<#
.Synopsis
Set UNIX attributes LoginShell in AD object
.DESCRIPTION
Set UNIX attributes in AD object
.EXAMPLE
PS C:\> Set-ADLoginShell -searchBase "OU=FacStaff,OU=Campus,DC=mike,dc=com" -value "/bin/bash"
#>
function Set-ADLoginShell
{
[CmdletBinding()]
[Alias()]
[OutputType([int])]
Param
(
# Set LoginShell value
[Parameter(Mandatory=$true,
ValueFromPipelineByPropertyName=$true,
Position=0)]
[string]$value,

# OU searchbase
[string]$searchBase
)

Begin
{
}
Process
{
Get-ADUser -Filter * -SearchBase $searchBase -Properties loginshell | Set-ADUser -Replace @{loginshell=$value} -Verbose
}
End
{
}
}

In line 31, the loginshell can be replaced by any attributes such as NIS Domain, UID Home Directory or GID.

You can run this cmdlet with -searchBase and -value parameters. $SearchBase is for the Organization Unit, and $value is the value in login shell attribute.

enable Unix ID 3

The result is reflected in the AD Object properties.

enable Unix ID 4

Categories:PowerShell

Recent Posts

  • Automating Resource Restriction in Azure subscriptions with Budget Alert, Automation Account, and Azure Policy
  • How to configure the Security Center via Azure Resource Manager (ARM) template
  • How to restrict Account Operators to see the password in LAPS
  • How to join a VM to a domain by PowerShell in Azure
  • How to push an existing repository from VS Code to Azure DevOps by PowerShell

Search

Categories

  • Azure
  • IIS
  • PowerShell
  • SCCM
  • VMware
  • Windows Server

Contact

Email: [email protected] | Powered By the 太初網路

Copyright © 2024 mikewu.org Disclaimer

Connect

FacebookTwitterGoogle +Linkedin